[求助]禁止输入其它符号,怎样完成
看一下代码For b = 1 To Text1.Text
Next
If b > 100 Then
MsgBox "献花"
Else
MsgBox "学习"
End If
禁止输入其它符号,只可以输入数字,怎样完成
text1.text=多少
[此贴子已经被作者于2007-7-4 15:38:39编辑过]
[此贴子已经被作者于2007-7-4 15:38:39编辑过]
也可以用這種方式,兩種作用一樣,就看你習慣哪一種
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
Else
KeyAscii = 0
End If
End Sub
你的这个方法使得键盘,只能用0-9键
现在连输入错误了,删除都删不了。
只能控制鼠标进行剪切
当然,我用鼠标也可以把字母复制进去,
怪我没说完,请大虾再改下,发出来。。。
无语...
如果是这样的话,要dim a as string
改为string又没办法判断a>100这些了!!!
不过还是要谢谢你,让我学到了另一个东西,,呵呵!!!
我改了一下
Dim a As String
a = Text1.Text
Dim a1 As Double
a2 = Text1.Text
If Not IsNumeric(a) Then
MsgBox "禁止输入其它符号,只可以输入数字"
Text1.Text = ""
Text1.SetFocus
Else
Select Case a2
Case 0 To 100
MsgBox "学习"
Case Is > 100
MsgBox "献花"
Case Is < 0
MsgBox "胎教"
End Select
End If
[此贴子已经被作者于2007-7-5 10:11:53编辑过]