Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1452to1456
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Code verkürzen

Code verkürzen
29.10.2015 16:44:05
PQuest:-)
Hallo,
wie könnte man diesen Code
...
For lngIndex = 1 To 17
With Controls("TextBox" & CStr(lngIndex))
If lngIndex = 17 And (.Value) = "" Then
Call MsgBox("Date of birth is required.", vbExclamation, "Date Required")
Call .SetFocus
.Text = vbNullString
blnWrongEntry = True
Exit For
ElseIf Not IsDate(.Value) And Not .Text = "" Then
Call MsgBox("Field ''" & .Tag & "'' do not contain a correct dateformat.", vbExclamation, "Hinweis")
Call .SetFocus
.Text = vbNullString
blnWrongEntry = True
Exit For
End If
End With
Next
...
so umstellen, dass man den Teil
Call .SetFocus
.Text = vbNullString
blnWrongEntry = True
Exit For
nur einmal schreiben muss?

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Code verkürzen
29.10.2015 17:51:17
Tino
Hallo,
vielleicht so.
Habe ich jetzt aber nicht getestet!
For lngIndex = 1 To 17
With Controls("TextBox" & CStr(lngIndex))
If lngIndex = 17 And .Value = "" Then
Call MsgBox("Date of birth is required.", vbExclamation, "Date Required")
blnWrongEntry = True
ElseIf Not IsDate(.Value) And Not .Text = "" Then
Call MsgBox("Field ''" & .Tag & "'' do not contain a correct dateformat.", _
vbExclamation, "Hinweis")
blnWrongEntry = True
End If
End With
If blnWrongEntry Then
Call .SetFocus
.Text = vbNullString
blnWrongEntry = False
Exit For
End If
Next
Gruß Tino

Anzeige
AW: Code verkürzen
29.10.2015 17:57:50
PQuest:-)
Ja... Danke!

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige