|
-
Sep 5th, 2001, 08:42 AM
#1
Thread Starter
New Member
Validation
I just look at an example on Master Karl's tutorial and need help. I am trying to passsword protect an application. I want the password to be a number, but I want to have control over what the person types in the password textbox.
EG.
ENTER YOUR PASSWORD ******
If the person types in letters, the computer will try to compare it with the pre - set numbers and return a TYPE MISMATCH error.
How can I change the VALIDATE event so that the computer will still return a "INCORRECT PASSWORD" as it would have done if the person types in an incorrect #?
THANKS
CBJ
-
Sep 5th, 2001, 08:51 AM
#2
Hyperactive Member
There was an exercise just like this in MS's MCSD material. Don't let it get as far as trying to check it, prevent the user typing a non-numeric in the first place. Assuming it's a text box, in the box's change event, use an if to check if the input's not numeric and so then empty the box.
-
Sep 5th, 2001, 09:05 AM
#3
Hyperactive Member
Or...
Alternatively, you could make your pre-set numbers not be numbers, but strings.
-
Sep 5th, 2001, 01:58 PM
#4
Lively Member
Taken from one of my Code collection
VB Code:
Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal _
dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const ES_UPPERCASE As Long = &H8&
Private Const ES_LOWERCASE As Long = &H10&
Private Const ES_NUMBER As Long = &H2000
Dim DefStyle&
Private Sub Form_Load()
DefStyle = GetWindowLong(txtEdit.hwnd, GWL_STYLE)
SetTextBoxType txtEdit, ES_NUMBER
End Sub
Private Sub SetTextBoxType(Txt As TextBox, tp As Long)
Call SetWindowLong(Txt.hwnd, GWL_STYLE, DefStyle Or tp)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|