Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

C++ to VB Conversion please ?

How would
[code] typedef unsigned char U8
static const U8 SELECT_FILE [] = {0x80, 0xA4, 0x00, 0x00, 0x02};[/code]

convert to VB ??

I'm thinking :
[code]Const SELECT_FILE(1 to 5) As String * 2 = "80 A4 00 00 02"[/code]

Am I wrong ???
Any help appreciated............

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : How would
    : [code] typedef unsigned char U8
    : static const U8 SELECT_FILE [] = {0x80, 0xA4, 0x00, 0x00, 0x02};[/code]
    :
    : convert to VB ??
    :
    : I'm thinking :
    : [code]Const SELECT_FILE(1 to 5) As String * 2 = "80 A4 00 00 02"[/code]
    :
    : Am I wrong ???
    : Any help appreciated............
    :

    Constants in VB cannot be arrays, so you are going to have to come up with a different approach.

    Greets...
    Richard

  • teeyesterteeyester Posts: 5Member
    : : How would
    : : [code] typedef unsigned char U8
    : : static const U8 SELECT_FILE [] = {0x80, 0xA4, 0x00, 0x00, 0x02};[/code]
    : :
    : : convert to VB ??
    : :
    : : I'm thinking :
    : : [code]Const SELECT_FILE(1 to 5) As String * 2 = "80 A4 00 00 02"[/code]
    : :
    : : Am I wrong ???
    : : Any help appreciated............
    : :
    :
    : Constants in VB cannot be arrays, so you are going to have to come up with a different approach.
    :
    : Greets...
    : Richard
    :
    :
    :Thanks for your reply Richard.....Whoops ! that do call for a....... reevaluation..........per conversations in other forums I've concluded that a byte array instead of a string would probably be the closest , Since the VB equivalent to an unsigned char is a byte...
    your thoughts ???
  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : : : How would
    : : : [code] typedef unsigned char U8
    : : : static const U8 SELECT_FILE [] = {0x80, 0xA4, 0x00, 0x00, 0x02};[/code]
    : : :
    : : : convert to VB ??
    : : :
    : : : I'm thinking :
    : : : [code]Const SELECT_FILE(1 to 5) As String * 2 = "80 A4 00 00 02"[/code]
    : : :
    : : : Am I wrong ???
    : : : Any help appreciated............
    : : :
    :
    : :
    : :Thanks for your reply Richard.....Whoops ! that do call for a....... reevaluation..........per conversations in other forums I've concluded that a byte array instead of a string would probably be the closest , Since the VB equivalent to an unsigned char is a byte...
    : your thoughts ???
    :

    That would depend on your usage. First let me note that:
    [code]
    Dim btNumber(1 To 2) As Byte
    btNumber(1) = &H8
    btNumber(2) = &H40
    [/code]
    Is not the same as:
    [code]
    Dim sNumber As String * 2
    sNumber = "48"
    [/code]
    This is because the numbers stored in string format are not equivalent to bytes.
    &H48 would make 01001000
    While "48" makes Asc("4") and Asc("8")
    Together making 52 and 56 and binary 00110100 00111000

    So it is also more bytes as well as being totally different numbers in memory.

    Because of this, the way to store the numbers depends on your usage.
    So how are you planning to use them in code?

    Greets...
    Richard

Sign In or Register to comment.