接收数组数据。求帮助。
Private Sub mscomm1_OnComm()
Dim indata As String
Dim num(1 To 40) As Integer
Dim j As Integer
For j = 1 To 40
Text2.Text = Text2.Text & Right(j + Hex(num(j)), 2)
Text2.Text = Text2.Text & " "
j = j & MSComm1.Input
Text2.Text = j
Next j
MSComm1.RThreshold = 1
End Sub
想用数组形式一个一个接收我所收到的数据可是总是读取到1~40的数字。谁能帮我修改一下这个程序。使mscomm控件能够一个一个接收到数据并一起显示出来
[解决办法]
Private Sub mscomm1_OnComm() Dim indata As String Dim num(1 To 40) As Integer Dim j As Integer Dim varP as Varaint MSComm1.RThreshold = 0 For j = 1 To 40 varP=Mscomm1.input if not isnull(varP) then num(j)=varP(0) endif Text2.Text = Text2.Text & Right(j + Hex(num(j)), 2) & " " Next j MSComm1.RThreshold = 1End Sub
[解决办法]
Private Sub mscomm1_OnComm() Dim indata As String Dim num(1 To 40) As Integer Dim j As Integer Dim varP as Varaint MSComm1.RThreshold = 0 For j = 1 To 40 varP=Mscomm1.input if not isnull(varP) then num(j)=varP(0) endif Text2.Text = Text2.Text & Right("00" & Hex(num(j)), 2) & " " Next j MSComm1.RThreshold = 1End Sub