-
January 1st, 2010, 01:22 AM
#1
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
I need the data to be in Hex so please lend a hand. Thanks.
Last edited by WizBang; January 2nd, 2010 at 07:48 AM.
Reason: Added [code] tags
Tags for this Thread
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
|