急!~ 大家帮帮忙!~
Option ExplicitPrivate Sub Command1_Click()
Dim si(1) As Byte
si(0) = &H63
si(1) = &H25
MSComm1.Output = si
End Sub
Private Sub Form_Load()
MSComm1.Settings = "9600,n,8,1"
= 1
MSComm1.InputLen = 0
MSComm1.InBufferSize = 1024
MSComm1.InBufferCount = 0
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim sData() As Byte
Dim strBuff As String
Dim i As Integer
Dim strdata As Variant
If = 2 Then
MSComm1.InputLen = 0
strBuff = MSComm1.Input
sData() = strBuff
For i = 0 To UBound(sData)
If Len(Hex(sData(i))) = 1 Then
strdata = strdata & "0" & Hex(sData(i))
Else
strdata = strdata & Hex(sData(i))
End If
Next
Text1 = strdata
Call DataClear
End If
Private Sub Timer1_Timer()
Dim sj(0) As Byte
sj(0) = &H3
MSComm1.Output = sj
End Sub
Public Sub DataClear()
MSComm1.OutBufferCount = 0
MSComm1.InBufferCount = 0
End Sub
当程序运行时,定时器 定时发送查询地址到单片机 自动回传数据 显示在电脑上 . 我手动按纽发送命令时候 有时候会发生 按纽控制不了的问题 应该就是数据有冲突的问题吧 该怎么解决 很急!~ 谢谢大家 能给点意见 怎么改进