阅读:2428回复:4
[求助]VB中如何在text中只能输入数字?
我是VB新手,在写作业中想在一个text中只输入数字,但是不知道怎么才能做到这点,望高手指点,感激不尽!
|
|
1楼#
发布于:2005-05-18 10:40
<P>控制acii码就行,不是数字的,不执行任何时间就ok</P>
|
|
|
2楼#
发布于:2005-05-18 16:40
<img src="images/post/smile/dvbbs/em12.gif" />
|
|
3楼#
发布于:2005-05-21 23:32
<P>Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim s As String * 1 s = Chr(KeyAscii) If InStr("0123456789-.,", s) = 0 And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub</P><P>用这个代码试试</P><img src="images/post/smile/dvbbs/em07.gif" /> |
|
4楼#
发布于:2005-05-21 23:32
<P>Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim s As String * 1 s = Chr(KeyAscii) If InStr("0123456789-.,", s) = 0 And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub</P><P>用这个代码试试</P><img src="images/post/smile/dvbbs/em07.gif" /> |
|