Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
572to576
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
572to576
572to576
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Problem mit on error

Problem mit on error
24.02.2005 08:00:06
Basti
Hallo nochmal,
habe ein problem mit dem einfügen des on error Befehls in diesen Code:

Private Sub txtAbreise_Change()
On Error GoTo FehlerDatum
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 Then
txtTage = DateValue(txtAbreise) - DateValue(txtAnreise)
End If
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 And txtPreisÜN <> "" Then
txtPreisGesamt = txtTage * txtPreisÜN
txtPreisGesamt = Format(txtPreisGesamt, "#####,##0.00")
End If
End Sub

Sub FehlerDatum()
MsgBox "Geben Sie das Datum im Format TT.MM.JJ ein !", 48, _
"Falsche Eingabe"
End Sub
Wenn ich das ganze jetzt laufen lassen und es entsteht ein Fehler, sagt er mir
Sprungmarke nicht definiert. Aber Sub ist im selben Codefenster angelegt.
Woran liegt das?
MfG
Basti

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Problem mit on error
Detlef
Hallo,
du musst die fehlersprungmarke im gleichen sub laufen lassen
Gruß
Detlef
AW: Problem mit on error
Jan
Hi Basti,
Nimm den Code so:

Private Sub txtAbreise_Change()
On Error GoTo FehlerDatum
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 Then
txtTage = DateValue(txtAbreise) - DateValue(txtAnreise)
End If
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 And txtPreisÜN <> "" Then
txtPreisGesamt = txtTage * txtPreisÜN
txtPreisGesamt = Format(txtPreisGesamt, "#####,##0.00")
End If
FehlerDatum:
MsgBox "Geben Sie das Datum im Format TT.MM.JJ ein !", 48, _
"Falsche Eingabe"
End Sub

Jan
Anzeige
AW: Problem mit on error
24.02.2005 08:04:45
Werner
Nochmal Guten Morgen Basti

Private Sub txtAbreise_Change()
On Error GoTo FehlerDatum
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 Then
txtTage = DateValue(txtAbreise) - DateValue(txtAnreise)
End If
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 And txtPreisÜN <> "" Then
txtPreisGesamt = txtTage * txtPreisÜN
txtPreisGesamt = Format(txtPreisGesamt, "#####,##0.00")
End If
Goto FINI
FehlerDatum:
MsgBox "Geben Sie das Datum im Format TT.MM.JJ ein !", 48, _
"Falsche Eingabe"
FINI:
End Sub

Die SprungMarke in der gleichen Sub definieren.
Gruss Werner
Anzeige
Danke, klappt wunderbar. (o.T.)
24.02.2005 08:09:00
Sebastian
.
Danke für die Rückmeldung OT:-)
24.02.2005 08:12:13
werner
AW: Problem mit on error
UweD
Hallo
so:

Private Sub txtAbreise_Change()
On Error GoTo FehlerDatum
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 Then
txtTage = DateValue(txtAbreise) - DateValue(txtAnreise)
End If
If Len(txtAbreise.Value) = 8 And Len(txtAnreise.Value) = 8 And txtPreisÜN <> "" Then
txtPreisGesamt = txtTage * txtPreisÜN
txtPreisGesamt = Format(txtPreisGesamt, "#####,##0.00")
End If
Exit Sub 'Ende wenn keine Fehler
FehlerDatum:
MsgBox "Geben Sie das Datum im Format TT.MM.JJ ein !", 48, _
"Falsche Eingabe"
End Sub

Gruß UWeD
Exit ist beste Lösung, Jan hat immer F-Meld owT
Luc

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige