Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Verification Command For VB6, Verification Issue

views
     
TSjackyap84
post Jan 21 2006, 02:24 PM, updated 20y ago

Casual
***
Junior Member
334 posts

Joined: Jan 2005


What is the command to verify the field for text box in VB6? If the text box only can accept characters, once the user key in numbers, it will prompt out a error msg. Anyone can show me the command?

The command below is only allow number to be key in.

Private Sub txtname_KeyPress(KeyAscii As Integer)

If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = 46 Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
Beep
End If

End Sub

What is the command to verify only characyers can be key in into textbox rather than number?

This post has been edited by jackyap84: Jan 21 2006, 02:42 PM
SincerePrayer
post Jan 22 2006, 11:25 AM

love to pray
Group Icon
Elite
1,120 posts

Joined: Jun 2005
jackyap84,


You may want to read the code below
CODE
Private Sub Text1_KeyPress(KeyAscii As Integer)
   ' check for the lower case
   If ((KeyAscii >= 97 And KeyAscii <= 122) And KeyAscii <> 96) Then
       ' OK
       Exit Sub
       
   ' check for upper case
   ElseIf (KeyAscii >= 65 And KeyAscii <= 90) Then
       ' ok
       Exit Sub
   End If
   
   
   ' all not ok
   KeyAscii = 0
End Sub



Happy Coding smile.gif

 

Change to:
| Lo-Fi Version
0.0135sec    0.72    5 queries    GZIP Disabled
Time is now: 23rd December 2025 - 05:54 AM