Tuesday, April 5, 2011

Hex-Value in Visual Basic

Can someone just help me refresh my mind?

How do you specify hex values in a Visual Basic 6 / VBScript Source?

It's not 0xABCD as it is in C++, that's what I can remember... It was something similar... But what?

From stackoverflow
  • msgbox hex(255)

    BlaM : No, the other way around. For example if I want to assign a hex-value to a variable, not to encode an integer to a hex string.
    Fredou : your correct, my mistake
  • Try &HABCD, that's how it works for most BASIC languages.

    BlaM : Great, thanks. That's it!
    schnaader : No problem. I always knew using PowerBasic for DOS would be useful for something ;)
  • &H<hex-value> if my memory serves my correctly.

    Like: &HABCD

  • VBScript/VBA/VB6 (and lower):

    Dim MyValue As Integer
    MyValue = &h1234
    

    VB (.NET Framework 2.0) and lower:

    Dim MyValue As Integer = &h1234
    

    VB (.NET Framework 3.0/3.5):

    Dim MyValue = &h1234
    

    All versions can use the same syntax as lower versions but not the other way around...

0 comments:

Post a Comment