|
-
Mar 4th, 2008, 09:54 PM
#1
Thread Starter
Member
[2008] How do i limit my textbox to accept only perticular characters.
[2008] How do i limit my textbox to accept only perticular characters.
means suppose i want the email textbox, then i'll accept only keys having
a-z,A-Z,_,0-9 only.
for phone number, i'll accept 0-9,- only.
Thanks in advance..
-
Mar 4th, 2008, 10:26 PM
#2
Re: [2008] How do i limit my textbox to accept only perticular characters.
heres how to write custom textboxes
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 4th, 2008, 10:44 PM
#3
Thread Starter
Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
They are the controls. i want it done through the codes. like in VB6. thanks sooo much.... waiting for your answer.
-
Mar 4th, 2008, 10:53 PM
#4
Lively Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
Write Proper handling code in KeyPress Event of the Textbox. Where
Parameter "e" contains the details of the key pressed. When an unwanted key is pressed add aline e.handled=True.
Encourage the fellow member’s efforts by rating
- ComIT Solutions
-
Mar 4th, 2008, 11:07 PM
#5
Thread Starter
Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
Please can u explain in more detail with coding. i'm new here. dont anything about that. please help me...
-
Mar 4th, 2008, 11:17 PM
#6
Lively Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Select Case e.KeyChar
Case "1","2","3","4","5","6","7","8","9","0"
Case Chr(keys.Back) '<----- to allow BackSpace
Case Else
e.Handled=True
End Select
End Sub
Encourage the fellow member’s efforts by rating
- ComIT Solutions
-
Mar 4th, 2008, 11:33 PM
#7
Thread Starter
Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
Thanks so much working.... but i have one problem also...
i have a Masked textbox in the project. when i click on that masked textbox. the cursor location goes to only the position. but i want it to be at the starting position just like the normal textbox.
please help me. i want to complete the project in 15 minutes itself.
i've to go to college at sharp 11 AM in india. :P
thanks in advance. waiting for your reply.
-
Mar 4th, 2008, 11:42 PM
#8
Lively Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
If I have understood ur question. the following code is sufficient
Code:
Private Sub MaskedTextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MaskedTextBox1.MouseClick
MaskedTextBox1.SelectionStart = 1
End Sub
Encourage the fellow member’s efforts by rating
- ComIT Solutions
-
Mar 4th, 2008, 11:43 PM
#9
Re: [2008] How do i limit my textbox to accept only perticular characters.
Have a try this one
Code:
Private Sub MaskedTextBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaskedTextBox1.Enter
MaskedTextBox1.SelectionStart = 0
End Sub
-
Mar 4th, 2008, 11:48 PM
#10
Thread Starter
Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
None are working
also you are doing right. also the your answers were right.
but still its sticking with the same position. donno why ?
Last edited by SwapsRulez; Mar 4th, 2008 at 11:58 PM.
-
Mar 4th, 2008, 11:56 PM
#11
Re: [2008] How do i limit my textbox to accept only perticular characters.
This worked for me
Code:
Private Sub MaskedTextBox1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MaskedTextBox1.MouseClick
MaskedTextBox1.SelectionStart = 0
End Sub
-
Mar 4th, 2008, 11:56 PM
#12
Lively Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
What is Not Working! Post the Code so that we can have a look and suggest u.
Encourage the fellow member’s efforts by rating
- ComIT Solutions
-
Mar 5th, 2008, 12:00 AM
#13
Thread Starter
Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
vb Code:
Private Sub Phone_Text_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Phone_Text.MouseClick
Phone_Text.SelectionStart = 1
End Sub
-
Mar 5th, 2008, 12:01 AM
#14
Re: [2008] How do i limit my textbox to accept only perticular characters.
That should be 0 instead of 1
Code:
Phone_Text.SelectionStart = 0
-
Mar 5th, 2008, 12:03 AM
#15
Thread Starter
Member
Re: [2008] How do i limit my textbox to accept only perticular characters.
Also not working for 0. i've tried enter event also. 
please help me.
-
Mar 5th, 2008, 12:05 AM
#16
Re: [2008] How do i limit my textbox to accept only perticular characters.
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
|