The missing C++ unsigned short integer in VB6

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Salgoud Dell

    #1

    The missing C++ unsigned short integer in VB6

    C++ has a variable type 'unsigned short int.' I am trying to write a VB6
    program that prints these out of a file made originally by C++. However,
    the unsigned short integer (1-65535) is not supported. Does anyone have a
    routine that will allow VB6 to read a C++ unsigned short int?

    Thanks

    Del


  • Alan Barker

    #2
    Re: The missing C++ unsigned short integer in VB6

    you could read two single bytes from the file and use a function like:

    Public Function MakeWord(msb As Byte, lsb As Byte) As Long
    MakeWord = CLng("&h" & Trim$(Hex(msb)) & Trim(Hex(lsb)))
    End Function

    Function takes two bytes and makes a C++ short integer(word) 16bit
    msb;Most significan byte, lsb;least signinficant byte, watch the byte order.

    VB does not support Unsigned data type so must return a long

    probably not the most efficient inplementation but serves as an example

    hope it helps, any probs....
    al.

    "Salgoud Dell" <salgoud@nomail .com> wrote in message
    news:<ca26kb$ks i$1@news.cfu.ne t>...[color=blue]
    > C++ has a variable type 'unsigned short int.' I am trying to write a VB6
    > program that prints these out of a file made originally by C++. However,
    > the unsigned short integer (1-65535) is not supported. Does anyone have a
    > routine that will allow VB6 to read a C++ unsigned short int?
    >
    > Thanks
    >
    > Del
    >
    >[/color]


    Comment

    • Bob Butler

      #3
      Re: The missing C++ unsigned short integer in VB6

      "Salgoud Dell" <salgoud@nomail .com> wrote in message news:<ca26kb$ks i$1@news.cfu.ne t>...[color=blue]
      > C++ has a variable type 'unsigned short int.' I am trying to write a VB6
      > program that prints these out of a file made originally by C++. However,
      > the unsigned short integer (1-65535) is not supported. Does anyone have a
      > routine that will allow VB6 to read a C++ unsigned short int?[/color]

      VB6 can read it into an Integer variable just fine. Values 32768 to
      65535 will be displayed as -32768 to -1 but you can either just use
      them that way or move the values to a Long and mask off the low 16
      bits to see the original values.

      Comment

      Working...