如何在VB中使TEXTBOX只能输入数字,并支持Ctrl+V粘贴?

来源:百度知道 编辑:UC知道 时间:2024/07/08 00:39:19

使TEXTBOX只能输入数字:

Private Sub Text1_Change()
Dim i As Integer
For i = 1 To Len(Text1.Text)
If IsNumeric(Mid(Text1.Text, i, 1)) Then
bIsNum = True
Else
bIsNum = False
End If
Next i

If bIsNum = True Then
'MsgBox "是数字"
Else
Text1.Text = ""
'MsgBox "不是数字"
End If
End Sub