Private Sub Command1_Click()
Dim outstring As String
Dim n As Long
outstring = Text1.Text
n = Len(outstring)
Call send(outstring, n)
End Sub
Private Sub send(outstring As String, n As Long)
Dim instring As String
MSComm1.InputLen = 0
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.RThreshold = 1
MSComm1.Output = outstring + Chr(&HD)
End Sub
Private Sub MSComm1_OnComm()
Dim instring As String
Select Case MSComm1.CommEvent
Case comEvReceive
If MSComm1.InputMode = comInputModeBinary Then
Dim R() As Byte
Dim Buff As Variant
MSComm1.InputLen = MSComm1.InBufferCount
Buff = MSComm1.Input
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
R = Buff
For i = LBound(R) To UBound(R)
Text2.Text = Text2.Text + CStr(Hex(R(i))) + " "
Next
End If
End Select
End Sub
每次单片机受到vb发得数据后会发送0X34,但是每次接受到的却是FF 34,这个是怎么回事啊,以下是我的单片机程序:
main()
{
inicom();
while(1)
{
de=0; //接收判定程序
while(RI==0);
RI=0;
de=1;
SBUF=0x34;
while(TI==0);
TI=0;
}
}