0% found this document useful (0 votes)
36 views2 pages

Introduction

This document provides code to validate user input in text boxes. It includes code to handle the click event of two buttons and keypress events of two text boxes. The code for the first text box and button only allows letters and spaces, while the code for the second only allows digits. Validation messages are displayed if blank or invalid characters are entered.

Uploaded by

fancybala
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

Introduction

This document provides code to validate user input in text boxes. It includes code to handle the click event of two buttons and keypress events of two text boxes. The code for the first text box and button only allows letters and spaces, while the code for the second only allows digits. Validation messages are displayed if blank or invalid characters are entered.

Uploaded by

fancybala
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Introduction

This article explains simple ways to validate user input in a text box.

Here is the code; let's say we have two textboxes named txt1 and txt2 and two
buttons btn1 and btn2. Add the code given below:

 Collapse
Private Sub btn1_Click(ByVal sender As [Link], _
ByVal e As [Link]) Handles [Link]

If ([Link] = "") Then


MsgBox("Blank not Allowed", [Link], "Verify")
Else
MsgBox([Link], [Link], "Verify")
End If

[Link]()
[Link]()
End Sub

Private Sub txt1_KeyPress(ByVal sender As Object, _


ByVal e As [Link]) _
Handles [Link]
If ([Link]([Link]) = False) Then
If ([Link]([Link])) Or ([Link]([Link])) Then
'do nothing
Else
[Link] = True
MsgBox("Sorry Only Character & Spaces Allowed!!", _
[Link], "Verify")
[Link]()
End If
End If
End Sub

Private Sub txt2_KeyPress(ByVal sender As Object, _


ByVal e As [Link]) _
Handles [Link]
If ([Link]([Link]) = False) Then
If ([Link]([Link])) Then
'do nothing
Else
[Link] = True
MsgBox("Sorry Only Digits Allowed!!", _
[Link], "Verify")
[Link]()
End If
End If
End Sub

Private Sub btn2_Click(ByVal sender As [Link], _


ByVal e As [Link]) Handles [Link]
If ([Link] = "") Then
MsgBox("Blank not Allowedt", [Link], "Verify")
Else
MsgBox([Link], [Link], "Verify")
End If

[Link]()
[Link]()
End Sub

You might also like