请求帮助:
我用VB编的一个通讯程序,不知怎么也接收不到数据,只能显示"?????????" 源程序如下,
请各位帮忙分析一下,问题出在什么地方:我的邮箱:leesnw@163.com
Function SumChek(DATA$) As String
Dim i&
Dim Chek&
For i = 1 To Len(DATA)
Chek = Chek + Asc(Mid(DATA, i, 1))
Next i
SumChek = Right(Hex$(Chek + 3), 2)
End Function
Private Sub CommDel_Click()
Text2.Text = ""
Text1.Text = ""
End Sub
Private Sub CommRead_Click()
Dim DATA As String
DATA = Text2.Text
MSComm1.Output = "02" + DATA + "03" + SumChek(DATA)
End Sub
Private Sub Form_Load()
Dim STX As String
Dim ETX As String
STX = Chr(2)
ETX = Chr(3)
MSComm1.Settings = "9600,e,7,1"
MSComm1.CommPort = 1
MSComm1.PortOpen = True
MSComm1.Handshaking = 0
MSComm1.InBufferCount = 0
MSComm1.OutBufferCount = 0
Text2.Text = "请输入数据"
Text1.Text = "数据接收窗"
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
Timer1.Enabled = False
End Sub
Private Sub Option1_Click()
End Sub
Private Sub Timer1_Timer()
If MSComm1.InBufferCount > 0 Then
Text1.Text = MSComm1.Input
End If
End Sub