ich schaffe es nicht, den folgenden Code (Hier wird die Jahrszahl nur zweistellig eingeben) so umzuschreiben, dass das Eingabedatum in der Form TTMMJJJJ (Jahreszahl vierstellig!) erfolgen muss und das Ausgabedatum dann in der Form TT.MM.JJJJ erscheint. Wer kann helfen.
Private Sub txtAntrag_Change()
Dim dteEingabe As Date
Dim iDay As Integer, iMonth As Integer, iYear As Integer
If txtAntrag.Text = "" Then Exit Sub
If Not IsNumeric(Right(txtAntrag.Text, 1)) Then
Beep
txtAntrag.SelStart = Len(txtAntrag.Text) - 1
txtAntrag.SelLength = 1
lblAusgabe.Caption = "Nur Ziffern erlaubt!"
Exit Sub
Else
lblAusgabe.Caption = ""
End If
iDay = CInt(Left(txtAntrag.Text, 2))
Select Case Len(txtAntrag.Text)
Case 0
Case 1
If iDay > 3 Then
Beep
txtAntrag.SelStart = 0
txtAntrag.SelLength = 1
lblAusgabe.Caption = "Maximal 31 Tage"
Else
lblAusgabe.Caption = ""
End If
Case 2
If iDay > 31 Then
Beep
txtAntrag.SelStart = 0
txtAntrag.SelLength = 2
lblAusgabe.Caption = "Maximal 31 Tage"
Else
lblAusgabe.Caption = ""
End If
Case 3
iMonth = CInt(Right(txtAntrag.Text, 1))
If iMonth > 1 Then
Beep
txtAntrag.SelStart = 2
txtAntrag.SelLength = 1
lblAusgabe.Caption = "Maximal 12 Monate"
Else
lblAusgabe.Caption = ""
End If
Case 4
iMonth = CInt(Right(txtAntrag.Text, 2))
If iMonth > 12 Then
Beep
txtAntrag.SelStart = 2
txtAntrag.SelLength = 2
lblAusgabe.Caption = "Maximal 12 Monate"
Else
lblAusgabe.Caption = ""
End If
Select Case iMonth
Case 2
If iDay > 29 Then
Beep
txtAntrag.SelStart = 0
txtAntrag.SelLength = 4
lblAusgabe.Caption = "Maximal 29 Tage"
Else
lblAusgabe.Caption = ""
End If
Case 4, 6, 9, 11
If iDay > 30 Then
Beep
txtAntrag.SelStart = 0
txtAntrag.SelLength = 4
lblAusgabe.Caption = "Maximal 30 Tage"
Else
lblAusgabe.Caption = ""
End If
End Select
Case 6
iMonth = CInt(Mid(txtAntrag.Text, 3, 2))
iYear = CInt(Right(txtAntrag.Text, 2))
If iYear Mod 4 > 0 And iMonth = 2 And iDay = 29 Then
Beep
txtAntrag.SelStart = 0
txtAntrag.SelLength = 6
lblAusgabe.Caption = "Maximal 28 Tage"
Else
txtAntrag.Text = DateSerial(iYear, iMonth, iDay)
dteEingabe = DateSerial(iYear, iMonth, iDay)
'lblAusgabe.Caption = dteEingabe & vbLf & Format(dteEingabe, "dddd")
txtAntrag.SelStart = 0
txtAntrag.SelLength = 6
'End If
txtFaelligkeit.SetFocus
txtFaelligkeit.SelStart = 0
txtFaelligkeit.SelLength = Len(txtFaelligkeit.Text)
End If
End Select
End Sub
Ich danke Euch.
Liebe Grüße aus Würzburg