在vb编程中,怎么让文本框里只接受数字
答案:2 悬赏:30 手机版
解决时间 2021-01-14 12:55
- 提问者网友:川水往事
- 2021-01-13 15:00
在vb编程中,怎么让文本框里只接受数字
最佳答案
- 五星知识达人网友:猎心人
- 2021-01-13 16:21
Dim a As String
Private Sub Form_Load()
a = ""
End Sub
Private Sub Text1_Change()
If IsNumeric(Text1.Text) Then
a = Text1.Text
Else
Text1.Text = a
End If
End Sub
Private Sub Form_Load()
a = ""
End Sub
Private Sub Text1_Change()
If IsNumeric(Text1.Text) Then
a = Text1.Text
Else
Text1.Text = a
End If
End Sub
全部回答
- 1楼网友:末日狂欢
- 2021-01-13 16:36
'只接受数字和退格
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > Asc("0") And KeyAscii < Asc("9") Or KeyAscii = 8 Then
Else
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > Asc("0") And KeyAscii < Asc("9") Or KeyAscii = 8 Then
Else
KeyAscii = 0
End If
End Sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯