slamet Harto
05-12-2008, 03:02 AM
Dear all
Is there a way to prevent any numeric or symbol in a userform
I use the following code, but seem does not work at all
Private Sub TxtCMName_Change()
TxtCMName.Text = UCase(Left(TxtCMName.Text, 30))
'To prevent any numerical or symbol
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ/!!@#$%^&*() ", Chr KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Other case:
Kindly advise me, what is my mistake with if function in userform
If total of digit at the textbox "Txtno" is not 15 digit or "Txtno" is blank
then show message box
Here is the code that I'm using.
If TxtNo.Text = "" Then
MsgBox "Enter the Number! ", vbInformation, "Error message"
TxtCard1.SetFocus
Exit Sub
ElseIf TxtNo.Text <> 15 Then
MsgBox "Invalid Card Number! ", vbInformation, "Please check total digit "
TxtCard1.SetFocus
Exit Sub
End if
Thanks for your assistance.
Best rgds, Harto
Edited by Aussiebear: to group the sections of code within the vba Tags
Is there a way to prevent any numeric or symbol in a userform
I use the following code, but seem does not work at all
Private Sub TxtCMName_Change()
TxtCMName.Text = UCase(Left(TxtCMName.Text, 30))
'To prevent any numerical or symbol
If InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ/!!@#$%^&*() ", Chr KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Other case:
Kindly advise me, what is my mistake with if function in userform
If total of digit at the textbox "Txtno" is not 15 digit or "Txtno" is blank
then show message box
Here is the code that I'm using.
If TxtNo.Text = "" Then
MsgBox "Enter the Number! ", vbInformation, "Error message"
TxtCard1.SetFocus
Exit Sub
ElseIf TxtNo.Text <> 15 Then
MsgBox "Invalid Card Number! ", vbInformation, "Please check total digit "
TxtCard1.SetFocus
Exit Sub
End if
Thanks for your assistance.
Best rgds, Harto
Edited by Aussiebear: to group the sections of code within the vba Tags