电视剧《旗袍》评分:VB中的textbox不能为英文or字符

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 12:16:35
Private Sub Command2_Click()
If Text1.Text = "" Or Text2.Text = "0" Or Text2.Text <> "qwertyuiopasdfghjklzxcvbnm" Then
MsgBox "A空不能为空或不能为零!"
Exit Sub
End If
If Text2.Text = "" Or Text2.Text = "0" Then
MsgBox "B空不能为空或不能为零!"
Exit Sub
End If
Label1 = Val(Text1.Text) / Val(Text2.Text)
End Sub

=====================================
VB中的textbox不能为英文or字符
textbox中不能为空,只能为数字,但也不能等于零,请把你的代码写在我源程序里面,谢谢!

可以使用函数Isnumeric
if not(isnumeric(text1.text)) then
msgbox "必须输入数字"
exit sub
end if
if text1.text=0 then
msgbox "不能输入0"
exit sub
end if
if not(isnumeric(text2.text)) then
msgbox "必须输入数字"
exit sub
end if
if text2.ext=0 then
msgbox "不能输入0"
exit sub
end if

可能你是想textbox中不能是or或者为空吧!
这样就可以了:
if text1.text="or" or text1.text="" then
MsgBox "不能为空或不能为or!"
endif

我估计你只想让文本框输入数字是吧?
其实没必要这么麻烦!
把文本框里边的值转换为数字型就可以了
val(text1.text)

private text1_change()
text1.text=val(text1.text)
end sub
这样,其实也很方便地!

英文和字符的条件:for i=1 to txt.length
asc(mid(txt,i,1)) > 0 and asc(mid(txt,i,1)) <255

用ASC码解决