Chr$(60 And &HFF)

petejk

Senior member
Apr 6, 2002
463
0
0

I dont understand what the "And" operator? does...

What is &HFF?
What do you think is its relevance as a parameter of Chr()




Thanks
 

Kermit

Member
Nov 29, 1999
115
0
0
&H prefix means the value is in hexadecimal. Hence the 255 value (15*16 + 15)
AND is boolean 'and' operator, if you and anything with &HFF, you get the lower 8 bits.
If you think VB is crap because of this, youshould see C.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Then this limits the variable to the range 0-255, the valid numbers for chr$.

var foo = 257

not valid for chr$ !

var bar = foo And &HFF

now bar = 1, a safe value.