VB.NET VALIDATION USING ASCII
For Numeric
Public Function OnlyNumeric(ByVal Key As String) As Boolean
If (Key >= 48 And Key <= 57) Or Key = 8 Then
OnlyNumeric = False
Else
OnlyNumeric = True
End If
End Function
--------------------------------------------------------------------------------------------
For Character
Public Function OnlyCharacter(ByVal key As String) As Boolean
If (key >= 65 And key <= 90) Or (key >= 97 And key <= 122) Or key = 8 Then
OnlyCharacter = False
Else
OnlyCharacter = True
MsgBox("Enter only characters")
End If
End Function
-----------------------------------------------------------------------------------------------
create this function and than call this function into that particular "textbox"(KeyPress event) like this way
Private Sub txtcitycode_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
e.Handled = OnlyNumeric(Asc(e.KeyChar))
End Sub
Private Sub txtcityname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcityname.KeyPress
e.Handled = OnlyCharacter(Asc(e.KeyChar))
End Sub
Dotnet, DotnetCore, Azure, C#,VB.net, Sql Server, WCF, MVC ,Linq, Javascript and Jquery
Subscribe to:
Post Comments (Atom)
Implementing OAuth validation in a Web API
I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...
-
ViewBag, ViewData, TempData and View State in MVC ASP.NET MVC offers us three options ViewData, ViewBag and TempData for passing data from...
-
// Export Datatable to Excel in C# Windows application using System; using System.Data; using System.IO; using System.Windows.Forms; ...
No comments:
Post a Comment
Comments Welcome