Public Class frmRechnungsdatum
    Public Datum As Date = CDate(Now.ToShortDateString)
    Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
        Label1.Text = ""
        If MyTextBox1.Text = "" Then Label1.Text = "Darf nicht leer sein!" : Me.DialogResult = DialogResult.None : Exit Sub
        If Not IsDate(MyTextBox1.Text) Then Label1.Text = "Falsches Format!" : Me.DialogResult = DialogResult.None : Exit Sub
        If CDate(MyTextBox1.Text) > CDate(Now.ToShortDateString) Then Label1.Text = "Muss heute oder früher sein!" : Me.DialogResult = DialogResult.None : Exit Sub
        If CDate(MyTextBox1.Text) < Now.AddMonths(-2) Then Label1.Text = "Zu alt!" : Me.DialogResult = DialogResult.None : Exit Sub
        Datum = CDate(MyTextBox1.Text)
        Me.DialogResult = DialogResult.OK
    End Sub

    Private Sub MyTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyTextBox1.KeyDown
        If e.KeyCode = Keys.Return Then
            btn.PerformClick()
        End If
    End Sub

    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Datum = CDate(Now.ToShortDateString)
        Me.Close()
    End Sub

    Private Sub frmRechnungsdatum_Load(sender As Object, e As EventArgs) Handles Me.Load
        MyTextBox1.Text = Now.ToShortDateString
    End Sub

End Class