English Sentence Loading...
英语句子加载中...
VB中Textbox控件只能输入数字
作者:junyuqin 日期:2009-08-29
我们在编写程序的时候,往往会禁止用户在输入框中输入一些字符,在VB中要做到这个功能,最简单的方法就是在用户输入字符的时候,给个判断就行了,下面是一个完整的事例。
Const xStr As String = "0123456789"
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = IIf(InStr(xStr & Chr(8), Chr(KeyAscii)), KeyAscii, 0)
If KeyAscii = 46 Then KeyAscii = 0
End Sub
Const xStr As String = "0123456789"
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = IIf(InStr(xStr & Chr(8), Chr(KeyAscii)), KeyAscii, 0)
If KeyAscii = 46 Then KeyAscii = 0
End Sub
评论: 0 | 引用: 0 | 查看次数: 4821