July 3, 2009

VB.Net- Enter AlphaNumeric Values

Private Sub txtRemark_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles

txtRemark.KeyPresse.Handled = OnlyAlphaNumeric(e.KeyChar)

End Sub

Public Function OnlyAlphaNumeric(ByVal Value As String) As Boolean
OnlyAlphaNumeric = True
If (Microsoft.VisualBasic.Asc(Value) >= 65 And Microsoft.VisualBasic.Asc(Value) <= 90) _ Or (Microsoft.VisualBasic.Asc(Value) >= 97 And Microsoft.VisualBasic.Asc(Value) <= 122) _ Or (Microsoft.VisualBasic.Asc(Value) >= 48 And Microsoft.VisualBasic.Asc(Value) <= 57) Then

OnlyAlphaNumeric = False

End If

If (Microsoft.VisualBasic.Asc(Value) = 32) Then OnlyAlphaNumeric = False End If

If (Microsoft.VisualBasic.Asc(Value) = 13) Then OnlyAlphaNumeric = False End If

End Function

No comments:

Post a Comment