Ich schaff es leider nicht
10.04.2020 20:04:55
MarC
Hallo Nepumuk,
ich weiß leider nicht wie ich den unten aufgeführten Code in für eine Klasse brauchbaren umwandel soll. Der Code soll ja nicht alle Textboxen einschränken sondern nur die Txt_Datum1,2,3,4... usw heißen.
Ich weiß nicht wie ich mich von einem Element spezifischen Sub lösen soll. Deine Beispiele sind interessant aber umsetzen kann ich es leider trotzdem nicht.
Könnte mir jemand hierbei helfen? Vll den Ansatz erklären?
Private Sub Txt_Datum_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If Len(Txt_Datum) = 0 Then
KeyAscii = 0
Else
If Len(Txt_Datum) - Len(Application.Substitute(Txt_Datum, ".", "")) = 2 Then
KeyAscii = 0
ElseIf Len(Txt_Datum) > 1 Then
If Mid(Txt_Datum, Len(Txt_Datum), 1) = "." Then
KeyAscii = 0
End If
End If
End If
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub Txt_Datum_Change()
If Txt_Datum.Tag "1" = True Then
If Len(Txt_Datum) = 2 Then
If InStr(Txt_Datum, ".") = 0 Then
Txt_Datum = Txt_Datum & "."
End If
ElseIf Len(Txt_Datum) = 4 Then
If Len(Txt_Datum) - Len(Application.Substitute(Txt_Datum, ".", "")) "." Then
Txt_Datum = Txt_Datum & "."
End If
End If
ElseIf Len(Txt_Datum) = 5 Then
If Len(Txt_Datum) - Len(Application.Substitute(Txt_Datum, ".", "")) "" Then
MsgBox "kein Datum!!!"
Txt_Datum = ""
End If
End Sub