If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Only Numbers")
e.Handled = True
End If
Attached image(s)
This post has been edited by Mangore: 15 October 2008 - 05:02 PM




Posted 15 October 2008 - 05:01 PM
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Only Numbers")
e.Handled = True
End If
This post has been edited by Mangore: 15 October 2008 - 05:02 PM
Posted 15 October 2008 - 05:10 PM
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Only Numbers")
e.Handled = True
End If
End Sub
Posted 15 October 2008 - 06:03 PM
jacobjordan, on 15 Oct, 2008 - 05:10 PM, said:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Only Numbers")
e.Handled = True
End If
End Sub
Posted 15 October 2008 - 06:24 PM
Mangore, on 15 Oct, 2008 - 06:03 PM, said:
jacobjordan, on 15 Oct, 2008 - 05:10 PM, said:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Only Numbers")
e.Handled = True
End If
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Only Numbers")
e.Handled = True
End If
Posted 15 October 2008 - 07:04 PM
This post has been edited by jacobjordan: 15 October 2008 - 07:04 PM
Posted 15 October 2008 - 07:55 PM
Posted 15 October 2008 - 08:37 PM
Posted 15 October 2008 - 08:56 PM
PsychoCoder, on 15 Oct, 2008 - 10:37 PM, said:
Posted 15 October 2008 - 10:43 PM
Posted 16 October 2008 - 07:44 AM
'list of valid characters allowed in textbox
'note if checking numbers, and the number is integer remove "."
'if checking numbers, and the number has decimals then further checking is required
Dim validCH() As Char = New Char() {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", Convert.ToChar(vbCr)}
Private Sub TextBoxNumOnly_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBoxNumOnly.KeyPress
Debug.WriteLine(Convert.ToByte(e.KeyChar))
If Array.IndexOf(validCH, e.KeyChar) <> -1 Then
'character was good code here
Exit Sub
End If
'character was bad code here
e.Handled = True
End Sub
Posted 16 October 2008 - 09:54 AM
Private Sub InputBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles InputBox.KeyDown
Select Case e.KeyCode
Case Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9
e.SuppressKeyPress = False
Case Keys.Decimal, Keys.OemPeriod
If Me.InputBox.Text.Contains(".") Then e.SuppressKeyPress = True
Case Keys.Subtract, Keys.OemMinus
If Me.InputBox.Text.StartsWith("-") Then e.SuppressKeyPress = True
Case Keys.Delete, Keys.Back, Keys.Enter, Keys.Return
e.SuppressKeyPress = False
Case Else
e.SuppressKeyPress = True
End Select
End Sub
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
