Only allow numeric values in the textbox

前端 未结 12 1032
南笙
南笙 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 03:57

    I used this code in my project:

    Private Sub txtReceiptID_KeyPress(KeyAscii As Integer)
    Dim Keychar As String
    If KeyAscii > 31 Then
        Keychar = Chr(KeyAscii)
        If Not IsNumeric(Keychar) Then
            KeyAscii = 0
        End If
    End If
    

    End Sub

提交回复
热议问题