Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hex Character conversion

Status
Not open for further replies.

bknepher

Programmer
Jun 13, 2001
7
0
0
US
Greetings,

Any ideas how to make this more elegant? It works but ...
An example of Full_CommandString would be "BEEF030600BAD2010000600100"

For ByteCounter = 1 To Len(Full_CommandString) - 1 Step 2
OutputCommand = OutputCommand & Chr(CByte("&H" & Mid(Full_CommandString, ByteCounter, 2)))
Next
MSComm1.Output = OutputCommand
Delay50ms
ResponseStatusCode = ""
ResponseStatusString = ""
ResponseStatusCode = MSComm1.Input
For ByteCounter = 1 To Len(ResponseStatusCode)
ResponseStatusString = ResponseStatusString & CStr(Hex(Val(Asc(Mid(ResponseStatusCode, ByteCounter, 1)))))
Next


Thanks.
 
That looks like it will work.
Stuff like this is never "elegant", since there's so much nesting involved.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top