Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,570
- Office Version
- 365
- 2016
- Platform
- Windows
I have this code:
I have a couple questions:
1) This chunk of code is supposed to chech the value of textbox Me.empl_number to ensure the user entered a 5 digit numerical value. My logic is that using Clng to convert the textbox string value to a number would err if there were anything but numbers in the string. I am getting an error with the line in red: "Type mismatch". Nothing is declared, becuase I don't know what to declare.
2)If there is an error (not a number), the code defaults the value in the textbox to "00000". I would like to highlight the this value to allow the user to type over it. Unsure how.
Rich (BB code):
Private Sub empl_number_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Stop
'invalid entry
If IsError(CLng(empl_given.Value)) Then
MsgBox "Not a number."
empl_number = "00000"
Cancel = True
Exit Sub
End If
End Sub
I have a couple questions:
1) This chunk of code is supposed to chech the value of textbox Me.empl_number to ensure the user entered a 5 digit numerical value. My logic is that using Clng to convert the textbox string value to a number would err if there were anything but numbers in the string. I am getting an error with the line in red: "Type mismatch". Nothing is declared, becuase I don't know what to declare.
2)If there is an error (not a number), the code defaults the value in the textbox to "00000". I would like to highlight the this value to allow the user to type over it. Unsure how.