[求助]vb的textbox控件
有谁知道让vb的textbox控件里面只能输入数值型数据的方法???????????急用,快告诉我,谢谢了!!!!!
还是不行啊。如果按下面的代码去运行的话,小数位就输不上了!!!!!(11楼所说,)另外怎么防止Ctrl+V 或鼠标右键粘贴???? Option Explicit
Private Sub Text1_KeyPress(KeyAscii As Integer) Dim Pos As Integer
If (KeyAscii < Asc("0") Or KeyAscii > Asc("9")) And KeyAscii <> Asc(".") And KeyAscii <> 8 Then KeyAscii = 0 End If Pos = InStr(Text1.Text, ".") If Pos <> 0 And KeyAscii <> 8 Then If KeyAscii = Asc(".") Then KeyAscii = 0 Else If Len(Mid(Text1.Text, Pos)) > 2 And Text1.SelStart >= Len(Text1.Text) - 2 Then KeyAscii = 0 End If End If End If End Sub 这个代码只针对键盘输入起作用,如果要防止Ctrl+V 或鼠标右键粘贴还要另加代码