C
Crirus
I need to allow only numbers into a text box
End said:I need to allow only numbers into a text box
One Handed Man said:In the KeyPress EventDim ch As String
ch = Chr$(KeyAscii)
If Not (ch >= "0" And ch <= "9") Then
' Cancel
KeyAscii = 0
Regards - OHM# (e-mail address removed)
Armin said:How to suppress inserting chars from the clipboard? ;-)
One Handed Man said:Hey, I cant write everything from scratch each time, I am after all
One Handed Man.
;-)
know it)How to suppress inserting chars from the clipboard? ;-) (saw it, but also
Crirus said:Any straight answer?
I need another inputs restrictions too, not only numeric
Hi Crirus,
As addition from the sample of OHM this sample.
And watch that you add with the sample of OHM the allowance of the
backspace 08 keyvalue other wise the user cannot make corrections)
You can in both samples of course use any character you want to
exclude. Although this is a value sample.
Cor
\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.textbox1.MaxLength = 2
End Sub
Private Sub textbox1_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles textbox1.KeyUp
If e.KeyValue <> 8 Then
If Not IsNumeric(textbox1.Text) OrElse CInt(textbox1.Text)
= 0 _ OrElse CInt(textbox1.Text) > 10 Then
MessageBox.Show("Only 1 to 10 is allowed")
textbox1.Focus()
End If
End If
End Sub
///
Right now I found MaskedEdit control ocx on google... there is one in NET?