Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

whats & means in VB?

Hi Guys,

I have a question here...it may be simple to some but is bothering me...

whats the function of & in VB? some times I see assignment statements like x& = ....

In graphics programming, whenever we need to get the RGB value, we use &H100& and &H10000<--for this case, how come there is no & at the end of the hexa, just like &H100&?? In RGB case, &H i believe it means Hexa right? what about binary?

Thanks alot for your time guys...
[478 byte] By [ootnitsuj] at [2007-11-11 8:10:04]
# 1 Re: whats & means in VB?
The & after a variable declares the variable a long, after a number "forces" the type of the number to be Long

That is:

dim i& ''is the equivalent of "dim i as long"
i = &hFFFF '' &hFFFF is a short (because the default is Integer), so i = -1
i = &hFFFF& '' &hFFFF& is a long, so i = 65535

Marco
mstraf at 2007-11-11 17:25:55 >
# 2 Re: whats & means in VB?
The '&' character is also used to concatenate things in VB.

For example:

Dim a As String
Dim b As String

a = "This is "
b = "an example."

Label1.Caption = a & b

The caption on the label would be: This is an example.
doofusboy at 2007-11-11 17:26:57 >