
vba程序如下,当把texbox1里的内容用Backspace键删除时,程序出错,显示类型不匹配,为什么?
PrivateSubTextBox1_Change()IfTextBox1.Text<=125ThenTextBox2.Enabled=TrueTextBox3.Enab...
Private Sub TextBox1_Change()
If TextBox1.Text <= 125 Then
TextBox2.Enabled = True
TextBox3.Enabled = False
TextBox4.Enabled = False
End If
If TextBox1.Text > 125 And TextBox1.Text <= 200 Then
TextBox2.Enabled = False
TextBox4.Enabled = False
TextBox3.Enabled = True
End If
If TextBox1.Text > 200 Then
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = True
End If
End Sub 展开
If TextBox1.Text <= 125 Then
TextBox2.Enabled = True
TextBox3.Enabled = False
TextBox4.Enabled = False
End If
If TextBox1.Text > 125 And TextBox1.Text <= 200 Then
TextBox2.Enabled = False
TextBox4.Enabled = False
TextBox3.Enabled = True
End If
If TextBox1.Text > 200 Then
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = True
End If
End Sub 展开
展开全部
在Private Sub TextBox1_Change()后面加一句
If TextBox1.Text = "" Or Not IsNumeric(TextBox1.Text) Then Exit Sub
PS: 你要判断的条件都是数字型的.当文本框为空或者输入的字符中不是数字的时候就会提示错误.
上面一句就是加一个判断 如果文本框为空或者文本框中输入的不是数字 就退出这个过程.
If TextBox1.Text = "" Or Not IsNumeric(TextBox1.Text) Then Exit Sub
PS: 你要判断的条件都是数字型的.当文本框为空或者输入的字符中不是数字的时候就会提示错误.
上面一句就是加一个判断 如果文本框为空或者文本框中输入的不是数字 就退出这个过程.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询