7,789
社区成员
发帖
与我相关
我的任务
分享Private Sub Command2_Click() '发送序列号按键
Dim outbyte1(0) As Byte
Dim number1 As Integer
Dim x As Integer, y As Integer
Command2.Enabled = False
Command3.Enabled = False
'While x = 0
If IsNumeric(Text3.Text) Then
If IsNumeric(Text4.Text) Then
If Val(Text4) < 1 Then
'x = 0
MsgBox "定时时间输入错误!", vbExclamation, "警告"
Text4 = ""
Command2.Enabled = True
End If
Else
'x = 0
MsgBox "定时时间输入错误!", vbExclamation, "警告"
Text4 = ""
Command2.Enabled = True
End If
If 0 < Val(Text3.Text) And Val(Text3.Text) < 100 Then 'text3.text是字符串,要用val转换,并且在vb中不能写成0 < Val(Text3.Text)<100要分开写
number1 = Text3.Text
outbyte1(0) = CByte(number1)
MSComm1.Output = outbyte1 '发送给序列号
Else
'x = 0
Text3.Text = ""
MsgBox "请输入正确的序列号!", vbOKOnly, "警告"
End If
Else
'x = 0
Text3.Text = ""
MsgBox "请输入正确的序列号!", vbOKOnly, "警告"
End If
'Wend
Timer1.Enabled = True
End Sub
If (Not IsNumeric(Text3.Text)) Or (Val(Text3.Text) < 1) Or (Val(Text3.Text) > 99) Then
MsgBox "请输入正确的序列号!", vbOKOnly, "警告"
Text3.Text = ""
Text3.SetFocus
Exit Sub
End If
If (Not IsNumeric(Text4.Text)) Or (Val(Text4.Text) < 1) Then
MsgBox "定时时间输入错误!", vbExclamation, "警告"
Text4.Text = ""
Text4.SetFocus
Exit Sub
End If
'你需要执行的代码