首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

接收数组数据。求帮助。解决办法

2012-03-11 
接收数组数据。求帮助。Private Sub mscomm1_OnComm()Dim indata As StringDim num(1 To 40) As IntegerDim

接收数组数据。求帮助。
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控件能够一个一个接收到数据并一起显示出来

[解决办法]

VB code
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
[解决办法]
VB code
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 

热点排行