I have written the code below on VB 2005 to try and restrict input on a textbox.
This code works very well on VB 2005 and its controls.
However my project's User interface (controls) are developed using Microsoft expression Blend and then I import the interface on VB 2005 and start coding.
Everything works well, however the code below does not work simply because the keyPress event is not available for my User interface.
So I'm wondering where else I can put the code below, or anything that might help.
Expand|Select|Wrap|Line Numbers
- Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
- Dim num As String = TextBox1.Text
- If IsNumeric(e.KeyChar) And num.Length < 10 Then
- e.Handled = False
- ElseIf AscW(e.KeyChar) = 8 Then
- e.Handled = False
- Else
- e.Handled = True
- End If
- End Sub