converting a buffer value

I am trying to add a 16bit value to my buffer. I have:

b(132116) = Convert.ToUInt16(tbHP.Text)

where:
b is my buffer array
tbHP.Text is the numeric value to add to the buffer.


The error I get says an arithmetic overflow occured. I am guessing this is because it is trying to set a 16bit value to an sbyte. I don't know how to correct this. Any ideas




Answer this question

converting a buffer value

  • Jennifer Peters

     

    Troy,

    Is the buffer a byte buffer You didn't specify the datatype.

    Again, you cannot add anything larger than an eight bit entity to a byte buffer - ever....

    there are a million ways to do this.

    dim a as ushort =  Convert.ToUInt16(tbHP.Text)

     

    b(132116) = a and &HFF

    b(132117) = (a >>8 ) and &HFF

     


     



  • converting a buffer value