|
-
Jun 5th, 2004, 09:28 AM
#1
Thread Starter
Lively Member
string manipulation
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?
-
Jun 5th, 2004, 10:51 AM
#2
The picture isn't missing
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.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jun 5th, 2004, 11:34 AM
#3
So Unbanned
-
Jun 5th, 2004, 01:13 PM
#4
Thread Starter
Lively Member
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?
-
Jun 5th, 2004, 03:49 PM
#5
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.
-
Jun 5th, 2004, 04:16 PM
#6
So Unbanned
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|