|
-
Nov 21st, 2012, 05:12 AM
#1
Thread Starter
Member
key down, suppress key problem
i have a telephone number textbox that i have used the key down event to suppress any other keys besides 0-9 and the backspace key. i have a label beside it.
i want to display a message on lbltelephone when the user presses an alphabetic key that the textbox is for numbers only,and the message should disapper when the user inputs correct values...
currently i have
e.suppresskeypress=true
lbltelephone.text="no"
-
Nov 21st, 2012, 05:18 AM
#2
Re: key down, suppress key problem
If keypress is invalid
do what you have done
Else
lbltelephone.text=""
end if
-
Nov 21st, 2012, 05:22 AM
#3
Thread Starter
Member
Re: key down, suppress key problem
this is the code i have, how do i incooperate your suggestion here?
Private Sub txtTel_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTel.KeyDown
If e.KeyCode = Keys.D0 Or e.KeyCode = Keys.D1 Or e.KeyCode = Keys.D2 Or e.KeyCode = Keys.D3 Or _
e.KeyCode = Keys.D4 Or e.KeyCode = Keys.D5 Or e.KeyCode = Keys.D6 Or e.KeyCode = Keys.D7 Or _
e.KeyCode = Keys.D8 Or e.KeyCode = Keys.D9 Or e.KeyCode = Keys.Back Then
Else
e.SuppressKeyPress = True
End If
If e.KeyCode = Keys.Escape Then
txtTel.Text = ""
End If
If e.KeyData = Keys.Return Then
txtPerson.Focus()
End If
End Sub
-
Nov 21st, 2012, 05:24 AM
#4
Re: key down, suppress key problem
@ Chris,
There was no need to start a new thread! I ask a mod to move the old one and have posted a vb.net solution in the thread here.
Edit:
See post #10.
Last edited by Nightwalker83; Nov 21st, 2012 at 05:24 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 21st, 2012, 05:32 AM
#5
Thread Starter
Member
Re: key down, suppress key problem
oh i didnt know, thanks, still xperiencing the same problem tho
-
Nov 21st, 2012, 09:09 AM
#6
Re: key down, suppress key problem
Code:
Private Sub txtTel_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTel.KeyDown
If e.KeyCode = Keys.D0 Or e.KeyCode = Keys.D1 Or e.KeyCode = Keys.D2 Or e.KeyCode = Keys.D3 Or _
e.KeyCode = Keys.D4 Or e.KeyCode = Keys.D5 Or e.KeyCode = Keys.D6 Or e.KeyCode = Keys.D7 Or _
e.KeyCode = Keys.D8 Or e.KeyCode = Keys.D9 Or e.KeyCode = Keys.Back Then
lbltelephone.Text = ""
Else
e.SuppressKeyPress = True
lbltelephone.Text = "No"
End If
If e.KeyCode = Keys.Escape Then
txtTel.Text = ""
End If
If e.KeyData = Keys.Return Then
txtPerson.Focus()
End If
End Sub
-
Nov 21st, 2012, 09:24 AM
#7
Re: key down, suppress key problem
What are you going to do if the user pastes a value into the textbox?
Tags for this Thread
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
|