如何使连个text都符合要求后,再一次执行!
下面的代码我是想要在按键按下后判断text3和text4都符合要求后在开始进行发送和延时,但语句好像不对程序代码:
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