
VB中编译错误子程序或主函数没定义。程序中那里出错误了
程序为PrivateSubTimer1_Timer()软件显示标出这里DimInbyte()AsByteDimbufferAsStringDimdatastr(20)As...
程序为Private Sub Timer1_Timer() 软件显示标出这里
Dim Inbyte() As Byte
Dim buffer As String
Dim datastr(20) As String
Inbyte = MSComm1.Input
For i = LBound(Inbyte) To UBound(Inbyte)
buffer = buffer + Hex(Inbyte(i)) + Chr(32) '获得单片机传送来的十六进制数
Next i
If buffer <> "" Then
'获得十六进制每一位
If Len(Trim(buffer)) = 1 Then 'Trim()函数是去掉返回数据2边的空格
datastr(1) = "0"
dasastr(2) = Trim(buffer) 软件显示标出这里
data16.Text = "0" & buffer '显示十六进制
End If
If Len(Trim(butter)) = 2 Then
datastr(1) = Mid(Trim(buffer), 1, 1)
datastr(2) = Mid(Trim(buffer), 2, 1)
data16.Text = buffer '显示十六进制
End If
datatemp(num) = (Val("&H" & datastr(1)) * (16 ^ 1) + Val("&H" & datastr(2)) * (16 ^ 0)) * 0.1
data10.Text = Format$(datatemp(num), "0.0") '十进制显示,保留一位小数
num = num + 1 '采集个数
Call Picture1_Click '调用绘制曲线过程
End If
End Sub
Private Sub Timer1_Timer() 和dasastr(2) = Trim(buffer) 这被软件错误标注了 展开
Dim Inbyte() As Byte
Dim buffer As String
Dim datastr(20) As String
Inbyte = MSComm1.Input
For i = LBound(Inbyte) To UBound(Inbyte)
buffer = buffer + Hex(Inbyte(i)) + Chr(32) '获得单片机传送来的十六进制数
Next i
If buffer <> "" Then
'获得十六进制每一位
If Len(Trim(buffer)) = 1 Then 'Trim()函数是去掉返回数据2边的空格
datastr(1) = "0"
dasastr(2) = Trim(buffer) 软件显示标出这里
data16.Text = "0" & buffer '显示十六进制
End If
If Len(Trim(butter)) = 2 Then
datastr(1) = Mid(Trim(buffer), 1, 1)
datastr(2) = Mid(Trim(buffer), 2, 1)
data16.Text = buffer '显示十六进制
End If
datatemp(num) = (Val("&H" & datastr(1)) * (16 ^ 1) + Val("&H" & datastr(2)) * (16 ^ 0)) * 0.1
data10.Text = Format$(datatemp(num), "0.0") '十进制显示,保留一位小数
num = num + 1 '采集个数
Call Picture1_Click '调用绘制曲线过程
End If
End Sub
Private Sub Timer1_Timer() 和dasastr(2) = Trim(buffer) 这被软件错误标注了 展开
展开全部
dasastr(2) 拼错了第三个字母,这Dim datastr(20) As String是你定义的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询