解决方案 »
- 有偿做提交表单,请大家帮帮我。
- 想把20051219等输入字符串转化成日期格式2005/12/19等,怎么转化??
- 为什么set mshflexgrid.datasource=rs之后,在mshflexgrid中显示表中第一条记录?
- 一个奇怪的问题,哪位高手能解决???????
- 如何在vb中到如flash动画
- 如何设置VB应用程序背景
- 请问:在VB中如何取到系统时间,格式为比如:12/03/2002?
- 文本框中光标位置是如何获得,谢谢高手!
- dbcombo1与dblist1的使用
- How to close IE winodws using vb program?
- 如何用代码执行指定的VB命令语句
- vb全屏控件问题
Dim str As String
Dim BytReceived() As Byte
Dim bytSendByte() As BytePrivate Sub MSComm1_OnComm()
Dim strBuff As String
Select Case MSComm1.CommEvent
Case 2
MSComm1.InputLen = 0
strBuff = MSComm1.Input
BytReceived() = strBuff
Dim i As Integer
For i = 0 To UBound(BytReceived)
If Len(Hex(BytReceived(i))) = 1 Then
str = str & "0" & Hex(BytReceived(i))
Else
str = str & Hex(BytReceived(i))
End If
Next
Text1.Text = str
Dim sj() As Byte
Dim sj_Txt As String
Dim q As Integer
sj_Txt = str
If Len(sj_Txt) Mod 2 = 0 And Len(sj_Txt) <> 0 Then
ReDim sj(Len(sj_Txt) / 2 - 1)
For q = 0 To Len(sj_Txt) - 1 Step 2
sj(q / 2) = Val("&H" & Mid(sj_Txt, q + 1, 2))
Next
MSComm1.Output = sj
str = ""
End If
End Select
End SubPrivate Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
MSComm1.RThreshold = 1
MSComm1.InBufferSize = 1024
MSComm1.PortOpen = True
End Sub
电脑接收后马上电脑写一段代码 以16进制把aa550108301017005f再发给单机片...发送怎么搞...
电脑接收后马上电脑写一段代码 以16进制把aa550108301017005f再发给单机片...发送怎么搞...还是接着问这个吧...
---------------------------------------------
你折腾半天与以代码有什么区别?Private Sub MSComm1_OnComm()
Dim strBuff() As byte
Select Case MSComm1.CommEvent
Case 2
MSComm1.InputLen = 0
strBuff = MSComm1.Input
BytReceived() = strBuff
jieshou
End Select MSComm1.Output = strBuff End If
end sub
Dim str As String
Dim BytReceived() As Byte
Dim bytSendByte() As Byte
Dim sj_Txt As StringPrivate Sub MSComm1_OnComm()
Dim strBuff As String
Select Case MSComm1.CommEvent
Case 2
MSComm1.InputLen = 0
strBuff = MSComm1.Input
BytReceived() = strBuff
Dim i As Integer
For i = 0 To UBound(BytReceived)
If Len(Hex(BytReceived(i))) = 1 Then
str = str & "0" & Hex(BytReceived(i))
Else
str = str & Hex(BytReceived(i))
End If
Next
Text1.Text = str
If Mid(str, 1, 2) = "AA" And Len(str) = 22 Then
sj_Txt = str
Timer1.Enabled = True
str = ""
End If
End Select
End SubPrivate Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeBinary
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
MSComm1.RThreshold = 1
MSComm1.InBufferSize = 1024
MSComm1.PortOpen = True
Timer1.Enabled = False
Timer1.Interval = 3000
End SubPrivate Sub Timer1_Timer()
Dim sj() As Byte
Dim q As Integer
If Len(sj_Txt) Mod 2 = 0 And Len(sj_Txt) <> 0 Then
ReDim sj(Len(sj_Txt) / 2 - 1)
For q = 0 To Len(sj_Txt) - 1 Step 2
sj(q / 2) = Val("&H" & Mid(sj_Txt, q + 1, 2))
Next
MSComm1.Output = sj
str = ""
End If
Timer1.Enabled = False
End Sub