Vb6 AscB to what in vbnet ?

  • Thread starter Thread starter Pascal
  • Start date Start date
P

Pascal

Hello can someone help please ?

here is the code in vb6
Dim lChar As Integer
lChar =AscB(Mid(sMessage, lByteCount + 1, 1))


i tried
lChar = System.Convert.ToUInt16(Asc(Mid(sMessage, lByteCount + 1, 1))) Mod
256

but somewhere i got an overflow capacity message error...

any idea would be appreciated
thanks

http://www.scalpa.info
 
Pascal said:
Hello can someone help please ?

here is the code in vb6
Dim lChar As Integer
lChar =AscB(Mid(sMessage, lByteCount + 1, 1))

Is there a reason why it was declard as integer, not as byte?
i tried
lChar = System.Convert.ToUInt16(Asc(Mid(sMessage, lByteCount + 1,
1))) Mod 256

but somewhere i got an overflow capacity message error...


b = CByte(Convert.ToUInt16(smessage.Chars(lbytecount)) And &HFFUS)


Or:

dim bytes as byte()
bytes = System.Text.Encoding.unicode.getbytes(smessage)

Then access the byte at position lByteCount*2

Also possible with an overloaded version to convert a substring only:

System.Text.Encoding.GetBytes(string, integer, integer, byte(), integer)



Armin
 
Pascal said:
Hello can someone help please ?

here is the code in vb6
Dim lChar As Integer
lChar =AscB(Mid(sMessage, lByteCount + 1, 1))


i tried
lChar = System.Convert.ToUInt16(Asc(Mid(sMessage, lByteCount + 1, 1))) Mod
256

but somewhere i got an overflow capacity message error...

any idea would be appreciated
thanks

http://www.scalpa.info

The AscB function works with 8 bit strings, there are no such strings in
..NET as strings are Unicode.

From where do you get the data, and what are you trying to do with it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top