杨超毅 最重要的决定:如何在VB中使TEXTBOX只能输入数字,并支持Ctrl+V粘贴?
来源:百度文库 编辑:中科新闻网 时间:2024/04/28 03:16:33
使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