Only allow numeric values in the textbox

前端 未结 12 924
南笙
南笙 2021-01-12 03:53

I want to make a TextBox control that only accepts numerical values.

How can I do this in VB6?

12条回答
  •  醉梦人生
    2021-01-12 04:05

    TRY THIS CODE: DISABLES LETTER(A-Z,a-z) AND ACCEPTS BACKSPACE, DOTS, COMMAS AND NUMBERS(0-9) =)

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If Not (KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ) And Not (KeyAscii >= 97 And KeyAscii <= 122) Then
    Else
    KeyAscii = 0
    End If
    End Sub

提交回复
热议问题