|
-
Dec 29th, 2010, 07:56 AM
#1
Thread Starter
Lively Member
[RESOLVED] Textbox must contain 4 numbers
Ok, I've made a textbox which MUST contain 4 numbers. If there are 3 numbers (or less) you'll get an error or something. I already changed the tabindex to 4. Does someone know how to accomplish this?
-
Dec 29th, 2010, 08:16 AM
#2
Addicted Member
Re: Textbox must contain 4 numbers
You can use the Len function to check the length of the textbox.
Code:
Dim what As String = TextBox1.Text
If Len(what) < 4 Then
MsgBox("no go")
Else
MsgBox("correct size")
End If
Above code can be used after a buttonclick or TextBox1_TextChanged to check instantly.
Paul
-
Dec 29th, 2010, 08:25 AM
#3
Re: Textbox must contain 4 numbers
You can also check if a number has been entered in the KeyPress event. If it is not a number set e.Handled to true (unless it is backspace chr(8)).
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Dec 29th, 2010, 08:42 AM
#4
Thread Starter
Lively Member
Re: Textbox must contain 4 numbers
Thanks both for your help! Hakka's method worked for me though.
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
|