help on textbox to accept numbers only ...thanks

 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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.