can you do the hex() thing in vb? i know you can in qbasic, and that will return the ascii hex value of the string in the parentheses correct?
Printable View
can you do the hex() thing in vb? i know you can in qbasic, and that will return the ascii hex value of the string in the parentheses correct?
hex() in VB will take a number and convert it to hex. to convert a string to hex, you would need to loop through each character and get the ascii value, then use hex on that.
Or just use my AscToHex function:
http://www.vbforums.com/showthread.p...hreadid=292448
;)
ok, how do you get the ascii value?
an looping through the string i can do it in qbasic, but how would you do it in vb?
You can take a look at digitalerror's code he linked to. But doing it the most normal (slow) way:
VB Code:
Dim A As Integer, Temp As String 'if we had textbox Text1 with some text... For A = 1 To Len(Text1.Text) Temp = Temp & " " & Hex$(Asc(Mid$(Text1.Text, A, 1))) Next A Text2.Text = Temp
So you get a single character with Mid$, then give it to Asc, and then Hex$ turns it to a hexadecimal. And it is included in to the string Temp which is displayed in textbox Text2.
A note when you convert using Hex(). The result may be only a single character.
Something like...
TmpChr = hex(asc(mid$(string,x,1))) 'w/e
strReturn = strReturn & string(2-len(tmpChr)) & tmpchr
But my method is MUCH faster. The memory is much more quickly allocated with the byte arrays. And avoiding strings for the actual processing(strings are SLOW... yet flexible).
I figure my method should be able to handle... on my system... atleast 30 MB/s. :D