2
Contributors
3
Replies
12
Views
3 Years
Discussion Span
Last Post by lloydsbackyard
0
 Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim str As String = Trim(TextBox1.Text)
        If Not Regex.Match(str, "^[0-9]*$", RegexOptions.IgnoreCase).Success Then
            MsgBox("Please enter Numbers text only.")
        Else
            MsgBox("O.K")
        End If
    End Sub

Sorry this was forvb.net

Edited by Minimalist: Wrong vb version

0

O.K. here we go for vb6

Private Sub Form_Load()
Text1 = ""
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
  If Not IsNumeric(Text1.Text & Chr(KeyAscii)) And Not KeyAscii = 8 Then
  KeyAscii = 0
  MsgBox ("Not a Number")
  End If
End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.