Imports System.Text.RegularExpressions

Public Class frmRegexEditor
    Public RegexString As String

    Public Sub New(RegexString As String)
        MyBase.New()

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        Me.RegexString = RegexString
    End Sub

    Private Sub RegexEditor_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtRegex.Text = RegexString
    End Sub

    Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
        RegexString = txtRegex.Text
        DialogResult = DialogResult.OK
        Close()
    End Sub

    Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
        Try
            Dim oTestString As String = txtTest.Text

            If Regex.IsMatch(oTestString, txtRegex.Text) Then
                labelResult.Caption = "Test String ist gültig."
            Else
                labelResult.Caption = "Test String ist nicht gültig."
            End If
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Regex Test")
        End Try
    End Sub
End Class