Results 1 to 3 of 3

Thread: change vb6 byte array default range

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2014
    Posts
    2

    change vb6 byte array default range

    i'm making a program that will export some data like a byte array...

    the program array is coded in VB6 and stored in database, but i need to read this data through java program.

    In vb6 we have the byte array filled by values that start at number 0 to number 255, but in the java the range is -127 at 128.

    Using vb6, how can i let the vb6 byte array on the java standard?

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: change vb6 byte array default range

    The VB6 Byte type is an unsigned 8-bit integer.

    Nothing prevents you from stuffing any bit pattern in there that you want. One possibility is to use VB6's Integer type (signed 16-bit integer) and move the lower 8 bits of that into a Byte.

    Such moves could be done a number of ways (GetMem1/PutMem1, CopyMemory, UDTS and LSet, etc.). The only tricky part may be moving back from a negative "signed byte" value into an Integer. Then you need to check the high bit of the Byte value and if set be sure to move &HFF into the high byte of the Integer variable as well as copying the Byte into the low byte.

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: change vb6 byte array default range

    It sounds like the byte array is already in the database, put in from VB6.
    You stated the range incorrectly, it would be -128 to 127 on the Java side.
    If the meaning of the value has to have its VB6 meaning, i.e. 0 to 255 when read on the Java side, then I would read the data into a Java byte array, then loop through and set elements of an Integer array to the value in the byte array + 128.
    If you had to write back to the database, then you would loop through the integer array and set the byte array value to integer value - 128.

    Rereading the post, I guess it you want the VB6 side to treat the numbers as -128 to 127, then as dilettante has already said, use integers on the VB6 side to maintain the -128 to 127 values.
    But you can still set just set the bytes in a byte array to the integer value + 128, before sending the byte array to the database, and do the reverse when reading them on the VB6 side.
    Last edited by passel; Mar 30th, 2015 at 06:09 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width