wie bekommt man eine Textbox dazu, dass in ihr ein "Punkt" enthalten sein muss?
Hat jemand einen Tipp?
Freundlicher Gruß
Thomas
If instr(textbox1,".")>0 then msgbox ok
Option Explicit
Dim BoEnter As Boolean
Private Sub TextBox6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
' erstellt von HajoZiplies@web.de Stand 01.08.03
' Datumseingabe 01.01.03;1.1.03 oder komlettes Jahr
' Eingabe des Tages und des Monat zweistellig werden die Punkte automatisch gesetzt
' sie können nur gelöscht durch markierung des punktes und der Zahl davor
' Buchstaben werden ausgeschlossen, nur Zahlen und Punkt
' die Überprüfung ob Datum erfolgt in Private Sub TextBox6_AfterUpdate()
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If Len(TextBox6) = 0 Then
KeyAscii = 0
Else
If Len(TextBox6) - Len(Application.Substitute(TextBox6, ".", "")) = 2 Then
KeyAscii = 0
ElseIf Len(TextBox6) > 1 Then
If Mid(TextBox6, Len(TextBox6), 1) = "." Then KeyAscii = 0
Else
KeyAscii = Asc(".")
End If
End If
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TextBox6_Change()
If BoEnter = True Then Exit Sub
If Len(TextBox6) = 2 Then
If InStr(TextBox6, ".") = 0 And BoEnter = False Then TextBox6 = TextBox6 & "."
ElseIf Len(TextBox6) = 5 Then
If Len(TextBox6) - Len(Application.Substitute(TextBox6, ".", "")) TextBox6 Then
MsgBox "Das Datum wurde übersetzt"
End If
TextBox6 = Format(CDate(TextBox6.Value), "dd.mm.yy")
Else
TextBox6 = ""
End If
BoEnter = False
End Sub
Gruß HajoPrivate Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'Eingabe im Format MM.JJJJ
Select Case KeyAscii
Case 48 To 57, 46
Select Case Len(TextBox1)
Case 0
If KeyAscii = 46 Then KeyAscii = 0
Case 1
If Clng(TextBox1) = 1 Then
If KeyAscii > 50 Then KeyAscii = 0
End If
Case 2
If KeyAscii <> 46 Then KeyAscii = 46
Case 3 To 6
If KeyAscii = 46 Then KeyAscii = 0
Case Else: KeyAscii = 0
End Select
Case Else: KeyAscii = 0
End Select
End Sub
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'Eingabe im Format MM.JJJJ
Select Case KeyAscii
Case 48 To 57, 46
Select Case Len(TextBox1)
Case 0
If KeyAscii = 46 Then KeyAscii = 0
Case 1
If Clng(TextBox1) = 0 Then
If KeyAscii = 46 Or KeyAscii = 48 Then KeyAscii = 0
ElseIf Clng(TextBox1) = 1 Then
If KeyAscii = 46 Or KeyAscii > 50 Then KeyAscii = 0
End If
Case 2
If KeyAscii <> 46 Then KeyAscii = 46
Case 3 To 6
If KeyAscii = 46 Then KeyAscii = 0
Case Else: KeyAscii = 0
End Select
Case Else: KeyAscii = 0
End Select
End Sub
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen