What is &H20 and &HDF in VBA?
-
03-10-2019 - |
Question
I am trying to grok the following piece of code:
Mid$(strV, i, 1) = Chr$(intChar And &HDF)
What does &HDF
mean? I also have a similar section that uses @H20
. I have Googled high and low and the most I found was nothing that I didn't already know about them...that they are constants.
Solution
That Visual Basic's hex notation. In C/C++/Java/C#, &HDF
would be written as 0xDF
.
Specifically, in your example, &HDF is 1101 1111
in binary. If a number in the range 0-255 (i.e., 0x00 - 0xFF) is ANDed with 0xDF, the 0x20 bit is set to zero. If that number happened to be in the range 97 - 122 (i.e. 'a' - 'z' in ASCII), it has the effect of converting it to the range 65 - 90 ('A' - 'Z' in ASCII)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow