|
-
Sep 2nd, 2008, 04:38 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2008] 1 to 9 digits only textbox
Hi!!
I'm creating a Sudoku Solver and as you know in a Sudoku you can only enter the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9. So in the textboxes of my program I have to limit the user input to these numbers. I went looking for a code for this in the forum and found this one from .paul.. This code is very good except that it also accepts the number 0. So I made my own:
Code:
Private Sub Textbox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Textbox1.TextChanged
Select Case e.KeyValue
Case Keys.Back, Keys.Delete, Keys.Left, Keys.Right, Keys.Home, Keys.End
Case Keys.D1 To Keys.D9, Keys.NumPad1 To Keys.NumPad9
If e.Modifiers <> 0 Then
e.SuppressKeyPress = True
e.Handled = False
End If
Case Else
e.SuppressKeyPress = True
e.Handled = False
End Select
End Sub
Everything works fine, from the exception that if I press Alt+0111 (or any other combination) I still get charater in the textbox (in this case an "o").
What is making me go crazy is that with If e.Modifiers <> 0 Then this input should be suppressed. How can I overcome this?
Thks a lot for the help!
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
|