VB中的 txtbox怎么样才可以只接收数字
我有两个txtbox是写数字的,VB中的 txtbox怎么样才可以只接收数字呢! --------------------编程问答-------------------- keypress事件中做判断 --------------------编程问答-------------------- IsNumeric("002")=true '是数字 --------------------编程问答-------------------- 在KeyPress事件中处理:Private Sub txtInput_KeyPress(KeyAscii As Integer)
If (KeyAscii < 0) Then KeyAscii = 0: Exit Sub
If (KeyAscii < 32) Then Exit Sub
If ((KeyAscii < 48) OR (KeyAscii > 57) Then KeyAscii = 0
End Sub
这样就只能输入数字了。 --------------------编程问答-------------------- KeyPress里判断一下Ascii就可以了 --------------------编程问答-------------------- If (KeyAscii<vbKey0 or KeyAscii>vbKey9) then
KeyAscii=vbCancel
endif --------------------编程问答-------------------- 1 --------------------编程问答-------------------- 判断ASCII值,3楼、5楼的就是! --------------------编程问答-------------------- Public Function Digit_Only(byval keyascii As integer) As Integer
Select Case keyascii
Case 8, 9, 13, &H2E, &H30 To &H39 '允许Tab, Back Space, Enter, 小数点和数字键
Digit_Only = keyascii
Case Else
Digit_Only = 0
End Select
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Digit_Only(KeyAscii)
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = Digit_Only(KeyAscii)
End Sub --------------------编程问答-------------------- 我也想知道,正在找這方面的資料~~~~~ --------------------编程问答-------------------- 有问题请先GOOGLE,BAIDU
补充:VB , 数据库(包含打印,安装,报表)