Public Class frmNacherfassungCRNEingabe

  
    Sub New(CRN)
        InitializeComponent()
        Me.CRN = CRN
    End Sub

    Public CRN = ""


    Private Sub btnFertig_Click(sender As Object, e As EventArgs) Handles btnFertig.Click
        CRN = ""
        CRN &= txtCRN1.Text
        CRN &= txtCRN2.Text
        CRN &= txtCRN3.Text
        CRN &= txtCRN4.Text

        If CRN.length <= 10 Or CRN.length > 20 Then
            MsgBox("Format nicht korrekt!" & vbNewLine & "Bitte prüfen Sie die Eingabe.")
            Me.DialogResult = DialogResult.None
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CRN = ""
    End Sub

    Private Sub frmNacherfassungCRNEingabe_Load(sender As Object, e As EventArgs) Handles Me.Load

        txtCRN1.Text = Format(Now, "yy")
        txtCRN2.Text = Format(Now, "AT")
        txtCRN3.Text = "320300"

        If CRN.length > 10 Then
            txtCRN1.Text = Mid(CRN, 1, 2)
            txtCRN2.Text = Mid(CRN, 3, 2)
            txtCRN3.Text = Mid(CRN, 5, 6)
            txtCRN4.Text = Mid(CRN, 11, 10)
        End If
    End Sub

    Private Sub frmNacherfassungCRNEingabe_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        txtCRN4.Focus()
    End Sub

    Private Sub returnKeyDown(sender As Object, e As KeyEventArgs) Handles txtCRN1.KeyDown, txtCRN2.KeyDown, txtCRN3.KeyDown, txtCRN4.KeyDown
        If e.KeyCode = Keys.Return Then
            btnFertig.PerformClick()
        End If
    End Sub
End Class

' Me!QKN = Trim(Nz(Me!QKN1, Format(Date, "yy")) & Nz(Me!QKN2, "AT") & Nz(Me!QKN3, "320300") & Nz(Me!QKN4, "          "))
       