|
-
Jun 28th, 2000, 03:13 AM
#1
Thread Starter
New Member
Does anyone know how to send "hex" through winsock? E.g. Something like...
Code:
HexData = 00 01 81 80 00 01 00 01 00 03 00 03 05 6C 6F 67
Winsock1.Senddata HexData
Or perhaps a function could help... such as...
Code:
Private Function EnHex(Hex as String)
'How could I code this?
End Function
Winsock1.Senddata EnHex("00 01 81 80 00 01 00 01 00 03 00 03 05 6C 6F 67")
Thanks. An example would be great.
-
Jun 28th, 2000, 04:01 AM
#2
Thread Starter
New Member
Also, another question
How do you convert hex into string? That's another question I have. Thanks.
-
Jun 28th, 2000, 04:10 AM
#3
Addicted Member
Hi,
I think you got some thinking to do here...
An HEX value is nothing diferent than an ASCII value, it's just the way YOU as a programmer see it in the variable.
Suppose you want to send these values to you socket
00 01 81 80
Winsock1.Senddata Chr(0) & chr(1) & chr(&h81) & chr(&h80)...
or you could have done this (which is exactly the same)
Winsock1.Senddata Chr(0) & chr(1) & chr(129) & chr(128)...
What you will receive in your winsock receive event is a string having unreadable caracters in it (little bars).
To have the value of this you must MID then ASC each of
the caracters one by one. value = asc(mid(str,1,1))
Perhaps I didn't understand your question but just I replied
just in case...
Bye
-
Jun 28th, 2000, 04:34 AM
#4
Thread Starter
New Member
Thanks a lot!
I am pretty new to hex values and I didn't know that they weren't ascii values. That helps me tremendously. Thanks!
-
Jun 28th, 2000, 05:42 AM
#5
New Member
How about something like 6F?
How could you convert something like 6F into a Chr()?
-
Jun 28th, 2000, 06:52 AM
#6
Hyperactive Member
Code:
Dim sHex as String
Dim sAscii as String
sHex = "6F"
sAscii = Chr(CInt("&h" & sHex))
MsgBox "The Ascii Value for " & sHex & " is (" & sAscii & ")"
In Visual Basic the value "&h" indicates a hex value. If you convert a string (where only numbers 0 to 9 and letters a to f are included) that has this at the front of it into an integer you get the equivalent ASCII value.
I would be VERY cautious of this however as any ASCII value < 32 could give you a control code and would give you strange results of ever displayed.
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
|