|
-
May 17th, 2004, 03:27 PM
#1
Thread Starter
New Member
Pop up box ?
Hello People,
i have a text box which only allows 2 digits to be entred, is there any way i can have a message box show if the user tries to enter 3 numbers?
or put some code on my button which checks to see if there is a value in the text box, at the moment if i click the enter button it crahses my programe, i would like it to say u have to enter a value first, so this cannot happen
Thank you people!!!
-
May 17th, 2004, 05:13 PM
#2
Sleep mode
Put this code in the change Event of the textbox
VB Code:
If textbox1.text.length > 2 then
messagebox.show("you're not allowed to enter more than 2 digits")
end if
-
May 17th, 2004, 05:59 PM
#3
Thread Starter
New Member
Thanks thats working great now, also could i limit the field size so only numbers 1 to 49 can be inputted?
do u know how i could validate the button cos at the moment if the user clicks the enter button without putting any data into the text boxes it crashes my programe?
Thanks
-
May 17th, 2004, 06:29 PM
#4
Sleep mode
In the keypress event , paste this code .
VB Code:
Dim KeyAscii As Integer
KeyAscii = Asc(e.KeyChar)
'only allow numbers, a single decimal point, backspace or enter
Select Case KeyAscii
Case Asc("0") To Asc("9"), Asc(ControlChars.Back)
'acceptable keys
e.Handled = False
Case Asc(ControlChars.Cr)
'enter key - move to next box
txtInterest.Focus()
e.Handled = False
Case Asc(".")
'check for existance of decimal point
If InStr(txtDeposit.Text, ".") = 0 Then
e.Handled = False
Else
e.Handled = True
End If
Case Else
e.Handled = True
End Select
-
May 17th, 2004, 06:36 PM
#5
Thread Starter
New Member
thanks i get this error back now
'Handled' is not a member of 'System.EventArgs'.
??
-
May 17th, 2004, 07:53 PM
#6
Sleep mode
Originally posted by TheOneWhoLearns
thanks i get this error back now
'Handled' is not a member of 'System.EventArgs'.
??
Where did you put this code ?
-
May 18th, 2004, 03:23 AM
#7
Thread Starter
New Member
Yeah got that working now, if i click the button now without any entries in the text boxes then it doesn't crash the programe, although if i put one entry into the textbox and then leave the others empty and click it, it still crashes!
Is there any way i can do this so that, it only performs its fucnction once all the textboxes have data in them, and if not it puts a pop up saying you must fill in all the text boxes?
Thank You!
-
May 18th, 2004, 04:27 AM
#8
Lose that message box about not entering 3 digits and just set the textbox's MaxLength property to 2.
Then you can query the number without worrying about the length of the data.
I don't live here any more.
-
May 18th, 2004, 06:28 AM
#9
Thread Starter
New Member
Originally posted by wossname
Lose that message box about not entering 3 digits and just set the textbox's MaxLength property to 2.
Then you can query the number without worrying about the length of the data.
ive done that now but how do i query the data?
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
|