Jabaco Source |
|
1 2 3 |
Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 |
Public Sub keyTyped(arg2 As KeyEvent) ' Eingabebegrenzung auf 0-9 Dim KeyCode As Integer KeyCode = arg2.getKeyChar If (KeyCode < arg2.VK_0) Or (KeyCode > arg2.VK_9) Then arg2.setKeyChar(0) End If |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Dim Buffer As String = "0" Public Sub Usercontrol_Initialize() Text1.Left = 0 Text1.Top = 0 Text1.Width = Me.Width Text1.Height = Me.Height Text1.Text="0" End Sub Public Sub Text1_KeyPress(KeyAscii As Integer) If ((KeyAscii < 47 Or KeyAscii > 57) And KeyAscii <> 8) Then Text1.Text = Buffer Else Buffer = Text1.Text End If End Sub Public Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer) If ((KeyCode < 96 Or KeyCode > 105) And KeyCode <> 8 And KeyCode <> 37 And KeyCode <> 38 And KeyCode <> 39 And KeyCode <> 40 ) Then Text1.Text = Buffer Else Buffer = Text1.Text End If End Sub Public Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) System.out.println(KeyCode) If ((KeyCode < 96 Or KeyCode > 105) And KeyCode <> 8 And KeyCode <> 37 And KeyCode <> 38 And KeyCode <> 39 And KeyCode <> 40 ) Then Text1.Text = Buffer Else Buffer = Text1.Text End If End Sub |
Jabaco Source |
|
1 |
Text1.Parent.addKeyListener(Me)
|
Jabaco Source |
|
1 |
If Text1.Parent.hasFocus = True Then |
You only need to do it one time in a Usercontrol. And then use the Usercontrol again and again.I would have to do that for every TextBox I need one for.