0% found this document useful (0 votes)
32 views13 pages

Msgbox and Errorprovider

The document discusses message boxes, error providers, and regular expressions in VB.NET. It provides examples of using regular expressions to validate dates, usernames/passwords, and email/phone numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views13 pages

Msgbox and Errorprovider

The document discusses message boxes, error providers, and regular expressions in VB.NET. It provides examples of using regular expressions to validate dates, usernames/passwords, and email/phone numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Experiment No 13 and 14

MessageBox
• It is a special dialogbox used to display the
information to the user
• It shows custom images to the user
parameters of message box:
1 Icon
2 Title
3 Buttons
1 Icon : to display icon like
critical,question,information and exclamation
2 Title: we can give a title to the message box
3 Buttons : we can display more than 1 buttons
with MsgBoxStyle option.
Error Provider
• Error provider is used to set validation errors.
• If user inputs wrong data ,it allows you to set
error message for a control.
Regular Expressions
• A regular expression is a pattern that could be
matched against inputted data,
RegularExpressions is also a namespace.
• The Regex is a class used for representing
regular expression.
Methods
• Public Function IsMatch(input as String) As Boolean
• Public Function IsMatch(input as String,startat Integer)
As Boolean
• Public Shared Function IsMatch(input as String,pattern
as String)As Boolean
• Public Function Matches(input as String) As
MatchCollection
• Public Function Replace(input as String,replacement as
String)As String
• Public Function Split(input as String ) As String()l
Expression Description
[a-z] Accept any character from a to z
[^a-z] Not Accepts any character from a-z
[0-9] Accept any digit from 0 to 9

[^0-9] Not Accepts any digit from 0-9

(x|y) Find any of the alternatives specified


WAP to validate Date
Imports System.Text.RegularExpressions

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim err As ErrorProvider = New ErrorProvider()
Dim regex As Regex = New Regex(“^[1-31]{1,2}[/|\|-][1-12]{1,2}[/|\|-][0-9]{4}$")
Dim isvalid As Boolean = True
isvalid = regex.IsMatch(TextBox1.Text)
If isvalid = False Then
err.SetError(TextBox1, "invalid error")
Else
MsgBox("valid date")

End If
End Sub
End Class
WAP to validate Username and pwd
Imports System.Text.RegularExpressions

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim err As ErrorProvider = New ErrorProvider()
Dim regex As Regex = New Regex(“^[a-zA-Z0-9]{3,20}@[A-Za-z]{3,10}.(com|in)$")
Dim isvalid As Boolean = True
isvalid = regex.IsMatch(TextBox1.Text)
If isvalid = False Then
err.SetError(TextBox1, "invalid email")

End If

Dim err1 As ErrorProvider = New ErrorProvider()


Dim regex1 As Regex = New Regex("[0-9A-Za-z!@#$%^&*]{8,10}$")
Dim isvalid1 As Boolean = True
isvalid1 = regex1.IsMatch(TextBox2.Text)
If isvalid1 = False Then
err.SetError(TextBox2, "invalid pwd")

End If
If isvalid = True And isvalid1 = True Then
MsgBox("welcome")
End If
End Sub
End Class
WAP to validate email and mobile no
Imports System.Text.RegularExpressions

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim err As ErrorProvider = New ErrorProvider()
Dim regex As Regex = New Regex(“^[a-zA-Z0-9]{3,20}@[A-Za-z]{3,10}.(com|in)$")
Dim isvalid As Boolean = True
isvalid = regex.IsMatch(TextBox1.Text)
If isvalid = False Then
err.SetError(TextBox1, "invalid email")

End If

Dim err1 As ErrorProvider = New ErrorProvider()


Dim regex1 As Regex = New Regex(“[7-9]{1}[0-9]{9}$")
Dim isvalid1 As Boolean = True
isvalid1 = regex1.IsMatch(TextBox2.Text)
If isvalid1 = False Then
err.SetError(TextBox2, "invalid mobile no")

End If
If isvalid = True And isvalid1 = True Then
MsgBox("welcome")
End If
End Sub
End Class

You might also like