If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to Convert ASCII to Hex?

[ Merged ]

Here's my code and the result, as much as I know, is in ASCII:

Code:

Private Sub Form_Load()
With MSComm1
.CommPort = 1
If .PortOpen = False Then
.PortOpen = True
End If
.DTREnable = True
.InputLen = 1
.RThreshold = 1
.Settings = "9600,n,8,1"
End With
End Sub
Private Sub MSComm1_OnComm()
Dim inbuffer() As Byte 'Declare an array of bytes
Dim i As Long
Select Case Me.MSComm1.CommEvent
Case comEvReceive
ReDim inbuffer(Me.MSComm1.InBufferCount) 'Specify the size of the array. InBuffercount gives the number of characters in the InputBuffer
inbuffer = Me.MSComm1.Input 'Read the InputBuffer
For i = 0 To UBound(inbuffer) 'Ubound(inbuffer) gives the upper bound of the array, which is equal to the number of characters in the InputBuffer
Me.Text1.Text = Me.Text1.Text & Chr$(inbuffer(i)) 'TxtReceive is a text box
Next i
End Select
End Sub

Re: How to Convert Hex to ASCII?

Actually the title is wrong. I need to convert it to hex (or decimal, etc) because the result is in ASCII. If I use the data I receive (which is in ASCII), I simply can't use it to make a command because it seems that VB6 can't comprehend the characters. Here's what I get and what I need to convert: