VB 6.0 - Validate only allow numeric

In this tutorial we will share about  Validate only allow numeric in form VB 6.0

VB 6.0 - Validate only allow numeric
Please design like above picture.
In above picture, we will validate Text3 and text4 only allow numeric.
for validate only allow numeric you can add code below
Private Sub text3_KeyPress(KeyAscii As Integer)
    If Not IsNumeric(Text3.Text & Chr(KeyAscii)) And Not KeyAscii = 8 Then KeyAscii = 0
End Sub
Or you can use below code :
Private Sub Text3_KeyPress(KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyReturn) Then KeyAscii = 0
End Sub
and the last you can run your project
You can click here to download project / source code above

Subscribe to receive free email updates:

0 Response to "VB 6.0 - Validate only allow numeric"

Post a Comment