|
Public Function SendHexDataString() As Boolean
Dim SendData As String
Dim buf() As Byte
Dim m, n, p As Long
Dim i, j, k As Long, cs
On Error Resume Next
SendHexDataString = False
SendData = "029c"
'SendData = strSendData'Trim(Text2.Text) '½«Òª•¢Ë͵Ä&Aumc0;&Aumc0;&Aumc;&Aumc;Ä0 ;¿Õ¸ñÈ¥³ý£¬²¢Ç&Oedil3;¸¸¸¸¸¸
If frmMain.MSComm1.PortOpen = False Then
frmMain.MSComm1.PortOpen = True
'MsgBox "Çë´ò¿ª´®¿Ú", vbOKOnly, "´íÎó"
'Exit Function
End If
If Len(SendData) = 0 Then 'Èç¹ûÎı¾¿òÄÚ&Atiluoyuo;´&Atiluoyue0;0uoe0acute0circle;0uoy0acute0;&
MsgBox "ÇëÊäÈëÊý¾Ý", vbOKOnly, "´íÎó"
Exit Function
End If
'If Check2.Value = 0 Then 'Èç¹ûûÓÐÑ¡Ô0uouo&uuo160e0circ;&uo16uotil0ecircle0;&uuo16uotilde;êle ;ÖÆ•¢ËÍ
'p = Len(SendData)
'ReDim buf(p-1) As Byte
'For i = 1 To p
'buf(i-1) = Asc(Mid(SendData, i, 1)) '½«Ã¿¸ö×Ö•ûÒÔ0;Ô0 #8226;¢ËÍ
'Next i
'Else 'Èç¹ûÑ¡ÔñÒÔ16½øÖø&AE0226
SendData = Replace(SendData, "", "")
SendData = Replace(SendData, vbCrLf, "")
p = Len(SendData)\2-1
ReDim buf(p) As Byte
For i = 0 To p
buf(i) = CLng("&H"&Mid(SendData, i * 2 + 1, 2)) 'ÒÔ16½øÖÆÊý•0uoE0l; ;
Next i
'End If
'ͨ¹ý´®¿Ú•¢ËÍÊý¾Ý¾Ý
frmMain.MSComm1.InputMode = comInputModeBinary
frmMain.MSComm1.Output = buf()
'Sleep (100)
'ProcGetData
SendHexDataString = True
Exit Function
'³ö´í´¦Àí
DoErr:
If Err.Number = 13 Then
MsgBox "Êý¾Ý¸ñʽ²»¶Ô", vbOKOnly, "´"´"
Else
MsgBox Err.Description
End If
End Function |
|