Author : Gehan Fernando
Date Submitted : 9/12/2007
Category : Forms
Compatibility : .NET
This code has been accessed 3139 times.
Task : Simple Regular Expressions Tester ....
Declarations
Code
Public Class Form1
Private Function TestRegularExpression(ByVal TestValue As Object, ByVal TestPattern As String) As Boolean
TestRegularExpression = False
If Regex.IsMatch(TestValue, TestPattern) Then
TestRegularExpression = True
Else
TestRegularExpression = False
End If
Return TestRegularExpression
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Ans As Boolean = False
Try
Ans = TestRegularExpression(TextBox2.Text.ToString().Trim(), TextBox1.Text.ToString().Trim())
If Ans = True Then
MessageBox.Show("Correct", "Regular Expressions", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Not Correct", "Regular Expressions", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error ...", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class