Function Isnumber(ByVal KCode As String) As Boolean
Isnumber = True
If Not IsNumeric(KCode) And KCode <> ChrW(Keys.Back) And KCode <> ChrW(Keys.Enter) And KCode <> "."c And KCode <> ","c Then
Isnumber = False
MsgBox("Please Enter Numbers only", MsgBoxStyle.OkOnly)
End If
End Function
Private Sub textbox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtAmount.KeyPress
If Not Isnumber(e.KeyChar) Then
e.KeyChar = ""
End If
End Sub