|
-
Apr 14th, 2006, 09:56 AM
#1
Thread Starter
Addicted Member
text box
i was wnodering how can you make a message box appear when
the person types letters instead of charictors in the text box ?!!!!!!!
an other question is that how can you make a massage box appear if there wasn't any @ in the textbox?!!?
thank you in advance
-
Apr 14th, 2006, 10:04 AM
#2
PowerPoster
Re: text box
youll be able to find answers to your questions by first searching the forum because a lot of the time, your question has been answered. for example, the @ sign question:
http://www.vbforums.com/showthread.p...validate+email
-
Apr 14th, 2006, 10:07 AM
#3
Thread Starter
Addicted Member
Re: text box
but what about the integer thing i couldn't find it?!!!
-
Apr 14th, 2006, 10:21 AM
#4
Hyperactive Member
Re: text box
there are lo of ways. Look in the ASC CODE CHART inside VB help to see the character's number.
And just put in the keypress event:
Select Case KeyAscii
Case 1 to 10, 15 to 20
KeyAscii = 0
MsgBox "TYPE ANOTHER CHAR!"
Exit Sub
End select
Of course instead of (1 to 10, 15 to 20) use all the chars you would like to filter.
About the other just use:
If InStr(1,Text1,"@") = 0 then msgbox "Please enter an @ in your textbox"
-
Apr 14th, 2006, 10:22 AM
#5
Re: text box
The only problem with creating a per key filter algorithm for a textbox is that it can't handle a copy and paste operation by the user (say data copied from notepad then pasted into the textbox). To compensate, patching additional code in the change event to recheck the string can get messy since you'll have to worry about the cursor position after correcting the input.
The best approach IMO, is to use the validate event. Check the input only after the user has finished entering the data for the textbox and has attempted to moved to another control. All other controls will have to have their CausesValidation property set to True.
-
Apr 14th, 2006, 10:38 AM
#6
Thread Starter
Addicted Member
Re: text box
i didn't get the folter thing to be honest
-
Apr 14th, 2006, 10:52 AM
#7
Thread Starter
Addicted Member
Re: text box
filter * thing i meant
-
Apr 14th, 2006, 11:37 AM
#8
Hyperactive Member
Re: text box
filter would be to "forbid" the user to use those chars.
for example, if you would like him not to use character's 20 to 30 and 40 to 45 then use
Select Case KeyAscii
Case 20 to 30, 40 to 45
KeyAscii = 0
MsgBox "TYPE ANOTHER CHAR!"
Exit Sub
End select
Of course i have no idea which cahrs those are... just was an example
EDIT:
And leinad31 is right, but if you know how will use the program and he's not stupid then you dont need to do anything... if the user could be a dumb person then you need to do something... I dont know what!
-
May 18th, 2006, 02:18 AM
#9
Member
Re: text box
I did not want to start a new thread so I thought I will post it here..
I would like to know the code required to be put in the keypress event of the textbox so that the user is allowed to enter only 0-9 and one decimal point..
And also disable copy and paste of data into the textbox..
-
May 18th, 2006, 02:44 AM
#10
Thread Starter
Addicted Member
Re: text box
would you explain it more
thank you
-
May 18th, 2006, 02:49 AM
#11
Member
Re: text box
Well i need a text box that accepts only number(0-9) and one decimal point..
it should not let the user enter alphabets..
this text box is to enter angles..
So it'l b of the format:
Eg: 56.678956 or 109.344532
So I want to implement validations for being able to only enter numbers and just 1 decimal point.
I hope that makes it clear
-
May 18th, 2006, 04:06 AM
#12
Re: text box
To allow only numric characters in Text box:
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Is < 32 ' Control keys are OK.
Case 48 To 57 ' This is a digit.
Case Else ' Reject any other key.
KeyAscii = 0
End Select
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
|