weixin_44431585
Penelope Cheng
采纳率0%
2019-07-26 11:16

VB 参数按地址传递,按值传递

作用:
将文件的每行放入lines()数组中;
行中是用空格分隔的,用split去除空格,放入arr()数组中
arr(1)为Signal名称,将其放入专门记录signal的数组SigArr和MsgArr中,并记录个数

调试时总是出错,比如:
1.数组维度超限
2.类型不匹配
3.split返回值不能赋给arr

请问要怎么改能实现上面的功能?

Type Signal
    Name As String
End Type

Type Message
    Name As String
    TxSig As String '由Message发送的Signal
End Type

Public MsgArr() As Message
Public SigArr() As Signal

Sub try()

Dim MsgCounter As Integer 'of MsgArr
Dim SigCounter As Integer 'of SigArr
Dim arr(30), lines(2) As String

MsgCounter = 0
SigCounter = 0

lines(0) = "SG_ DAQ_U8 : 15|8@0+ (1,0) [0|0] ""  Tool_transmitting_CCP"
arr = Split(lines(0), " ")

SignalAnalyze arr, SigCounter, MsgCounter

End Sub

Private Sub SignalAnalyze(arr() As String, ByRef SigCounter As Integer, ByRef MsgCounter As Integer)

SigArr(SigCounter).Name = arr(1)
MsgArr(MsgCounter).TxSig = MsgArr(MsgCounter).TxSig & vbLf & arr(1)

SigCounter = SigCounter + 1
MsgCounter = MsgCounter + 1

End Sub

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐