请发EMAIL给我
summer_sunjie@sina.com
部分源代码在这里
Private Sub Hexsent() '·¢ËÍ×Ó³ÌÐò
Stxt.Text = txtSend + RTUCRC
Dim hexchrlen%, hexchr As String, hexcyc%, hexmid As String
Dim i, j As Integer
hexchrlen = Len(Stxt)
For hexcyc = 1 To hexchrlen 'hexcyc=1to16 ¼ì²é·¢Ë͵ÄÊýÖµÊÇ·ñºÏÊÊ
hexchr = Mid(Stxt, hexcyc, 1)
If InStr("0123456789ABCDEFabcdef", hexchr) = 0 Then
MsgBox "ÎÞЧµÄÊýÖµ£¬ÇëÖØÐÂÊäÈë", , "´íÎóÐÅÏ¢"
Exit Sub
End If
Next
ReDim outbyte(1 To hexchrlen / 2) As Byte
For i = 1 To hexchrlen / 2
hexcyc = 2 * i - 1
hexchr = Mid(Stxt, hexcyc, 2)
hexmid = CStr(hexchr)
outbyte(i) = Val("&H" + hexmid)
Next i
ctrMSComm.Output = outbyte()
End Sub
'´Ë´¦Ìí¼Ó´¦Àí½ÓÊյĴúÂë
' hexstring = ctrMSComm.Input
' i = Len(hexstring)
' For j = 1 To i
' hexchr = Mid(hexstring, j, 1)
' If Hex(Asc(hexchr)) < 16 Then 'Èç¹ûhexchr(asc(chr)>128 Òç³ö Ϊ3F
' txtReceive.Text = txtReceive.Text & "0" & Hex(Asc(hexchr)) & " "
' Else
' txtReceive.Text = txtReceive.Text & Hex(Asc(hexchr)) & " "
' End If
''txtReceive.Text = txtReceive.Text & ctrMSComm.Input & CStr(Chr(13)) & CStr(Chr(10))
' Next j