Re: Datumseingabe in Textbox, Userform
07.04.2003 09:51:45
FCH
Hi Hajo,Das wirst du wohl nicht verhindern können, da für VBA der 12.25.2003 nunmal ein Datum ist.
Kannst du nicht eine zusätzliche Prüfung einfügen, nach dem Motto, der Monat darf nicht größer als 12 sein:
Private Sub TextBox6_AfterUpdate()
' Jahreszahl vom aktuellen Jahr ergänzen falls nicht vorhanden
If Len(TextBox6) - Len(Application.Substitute(TextBox6, ".", "")) = 1 And CDbl(Right(TextBox6, 2)) < 13 Then
TextBox6 = TextBox6 & "." & Year(Date)
End If
If IsDate(TextBox6.Text) And CDbl(Right(TextBox6, 2)) < 13 Then
If Format(CDate(TextBox6.Value), "dd.mm.yy") <> TextBox6 Then
MsgBox "Das Datum wurde übersetzt"
End If
TextBox6 = Format(CDate(TextBox6.Value), "dd.mm.yy")
Else
TextBox6 = ""
End If
End Sub
Gruß
FCH