VB按键出错求解!!!急
代码如下:Private Sub Command1_Click()
Dim Senddata(56) As Byte
Dim templong As Long
Dim tempuint As Integer
Dim tempbyte As Byte
Dim Sendstr As String
Dim k As Byte
On Error GoTo err
Sendata(0) = "&HFE"
Sendata(1) = "&H68"
Sendata(2) = "&H11"
Sendata(3) = "&H11"
Sendata(4) = "&H11"
Sendata(5) = "&H11"
Sendata(6) = "&H11"
Sendata(7) = "&H11"
Sendata(8) = "&H68"
Sendata(9) = "&H14"
Sendata(10) = "&H2C"
Sendata(11) = "&H00"
Sendata(12) = "&H20"
Sendata(13) = "&HF8"
Sendata(14) = "&H04"
Sendata(15) = "&H03"
Sendata(16) = "&H00"
Sendata(17) = "&H00"
Sendata(18) = "&H00"
Sendata(19) = "&H00"
Sendata(20) = "&H00"
Sendata(21) = "&H00"
Sendata(22) = "&H00"
templong = Val(changshu.Text)
tempbyte = templong Mod 256
Sendata(23) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(24) = "&H" + Hex(tempbyte) 'Const 发送时,高位在前,低位在后。其他标准值数据均是低位在前,高位在后
templong = Val(Text1.Text) * 100 'A voltage
tempbyte = templong Mod 256
Sendata(25) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(26) = "&H" + Hex(tempbyte)
templong = Val(Text2.Text) * 100 'B voltage
tempbyte = templong Mod 256
Sendata(27) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(28) = "&H" + Hex(tempbyte)
templong = Val(Text3.Text) * 100 'C voltage
tempbyte = templong Mod 256
Sendata(29) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(30) = "&H" + Hex(tempbyte)
templong = Val(Text4.Text) * 1000 'A current
tempbyte = templong Mod 256
Sendata(31) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(32) = "&H" + Hex(tempbyte)
templong = Val(Text5.Text) * 1000 'B current
tempbyte = templong Mod 256
Sendata(33) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(34) = "&H" + Hex(tempbyte)
templong = Val(Text6.Text) * 1000 'C current
tempbyte = templong Mod 256
Sendata(35) = "&H" + Hex(tempbyte)
tempbyte = Int(templong / 256)
Sendata(36) = "&H" + Hex(tempbyte)
templong = Val(Text8.Text) * 10
tempbyte = templong Mod 256
tempuint = templong / 256
Sendata(37) = "&H" + Hex(tempbyte)
tempbyte = tempuint Mod 256
Sendata(38) = "&H" + Hex(tempbyte)
tempbyte = tempuint / 256
Sendata(39) = "&H" + Hex(tempbyte)
templong = Val(Text9.Text) * 10
tempbyte = templong Mod 256
tempuint = templong / 256
Sendata(40) = "&H" + Hex(tempbyte)
tempbyte = tempuint Mod 256
Sendata(41) = "&H" + Hex(tempbyte)
tempbyte = tempuint / 256
Sendata(42) = "&H" + Hex(tempbyte)
templong = Val(Text21.Text) * 10
tempbyte = templong Mod 256
tempuint = templong / 256
Sendata(43) = "&H" + Hex(tempbyte)
tempbyte = tempuint Mod 256
Sendata(44) = "&H" + Hex(tempbyte)
tempbyte = tempuint / 256
Sendata(45) = "&H" + Hex(tempbyte)
templong = Val(Text22.Text) * 10
tempbyte = templong Mod 256
tempuint = templong / 256
Sendata(46) = "&H" + Hex(tempbyte)
tempbyte = tempuint Mod 256
Sendata(47) = "&H" + Hex(tempbyte)
tempbyte = tempuint / 256
Sendata(48) = "&H" + Hex(tempbyte)
templong = Val(Text23.Text) * 10
tempbyte = templong Mod 256
tempuint = templong / 256
Sendata(49) = "&H" + Hex(tempbyte)
tempbyte = tempuint Mod 256
Sendata(50) = "&H" + Hex(tempbyte)
tempbyte = tempuint / 256
Sendata(51) = "&H" + Hex(tempbyte)
templong = Val(Text24.Text) * 10
tempbyte = templong Mod 256
tempuint = templong / 256
Sendata(52) = "&H" + Hex(tempbyte)
tempbyte = tempuint Mod 256
Sendata(53) = "&H" + Hex(tempbyte)
tempbyte = tempuint / 256
Sendata(54) = "&H" + Hex(tempbyte)
If Check1.Value = 1 Then
tempbyte = Val(Text19.Text)
Sendata(59) = "&H" + Hex(tempbyte)
m = 59
Call Add33
For k = 0 To 61
Senddata(k) = Sendata(k)
Next k
Else
m = 54
Call Add33
For k = 0 To 56
Senddata(k) = Sendata(k)
Next k
End If
index = 12
MSComm1.OutBufferCount = 0
MSComm1.Output = Senddata
MSComm1.RThreshold = 13
MSComm1.InBufferCount = 0
Command4.Enabled = True
err:
Load Me
End Sub
运行后,如果不在文本框中输入数据或输入数据不超过3个,则按键Click可以响应,如果输入的数据超过3个,则Click事件不响应
这是怎么回事呢?是因为数据太多吗?