View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default When do you need .Value?

The reason I asked is that the On-line help attributes the availability
of the syntax

Range("a1:d4").Cells(1,2) [rather than Range("a1:d4").Cells.Item(1,2)],
thus by implication Range("a1:d4")(1,2) [rather than
Range("a1:d4.Item(1,2)],

to the fact that the Item Property is the default for the Range Object,
to wit:

"Because the Item property is the default property for the Range object,
you can specify the row and column index immediately after the Cells
keyword." [from the online help for the Cells Property]

Is the syntax Range("a1:d4")(1,2) not available in VB.Net to refer to
Cell B1?

Alan Beban

Tushar Mehta wrote:

Just that, Alan. The software will not make an inference about what
property it should refer to. So,

Dim x as Integer
x=Cells(1,1)

will not be interpreted as
x=Cells(1,1).Value

but an attempt to assign an object, i.e., Cells(1,1), to an integer
variable (x).

After all, .Net doesn't require a Set to assign an object to a
variable. So, if it supported a default property concept, the
following would be ambiguous:

Dim x as Variant
x=Cells(1,1)