Option
Explicit
Dim
strWeiterSo
As
String
Dim
strFehler
As
String
Dim
strHinweis
As
String
Private
Sub
UserForm_Initialize()
strWeiterSo =
"Mach weiter so, dann schaffst du die Bahnen unter 18."
strFehler =
"Du hast nur 6 Schläge!"
strHinweis =
"Bitte gültigen Wert eingeben."
Dim
n
As
Integer
For
n = 1
To
4
Me
.Controls(
"Bahn"
& n).Value =
"?"
Next
n
Textbox1.Value = 0
Textbox2.Value = 0
Textbox3.Value = 0
End
Sub
Private
Sub
Berechne()
Dim
n
As
Integer
Textbox1.Value = 0
Textbox2.Value = 0
Textbox3.Value = 0
For
n = 1
To
4
If
Me
.Controls(
"Bahn"
& n).Value = 1
Then
Textbox1.Value = Textbox1.Value + 1
End
If
If
Me
.Controls(
"Bahn"
& n).Value > 2
And
IsNumeric(
Me
.Controls(
"Bahn"
& n).Text)
Then
Textbox2.Value = Textbox2.Value +
Me
.Controls(
"Bahn"
& n).Value - 2
End
If
If
IsNumeric(
Me
.Controls(
"Bahn"
& n))
Then
Textbox3.Value = Textbox3.Value + Val(
Me
.Controls(
"Bahn"
& n).Text)
End
If
Next
n
End
Sub
Private
Sub
Bahn1_Exit(
ByVal
Cancel
As
MSForms.ReturnBoolean)
Dim
varWert
As
Variant
If
IsNumeric(Bahn1.Value)
Then
varWert = Bahn1.Value
Else
MsgBox strHinweis
Cancel =
True
Exit
Sub
End
If
If
varWert > 7
Then
MsgBox strFehler
Cancel =
True
Exit
Sub
End
If
If
varWert = 0
Then
MsgBox strWeiterSo
End
If
Call
Berechne
End
Sub
Private
Sub
Bahn2_Exit(
ByVal
Cancel
As
MSForms.ReturnBoolean)
Dim
varWert
As
Variant
If
IsNumeric(Bahn2.Value)
Then
varWert = Bahn2.Value
Else
MsgBox strHinweis
Cancel =
True
Exit
Sub
End
If
If
varWert > 7
Then
MsgBox strFehler
Cancel =
True
Exit
Sub
End
If
If
varWert = 0
Then
MsgBox strWeiterSo
End
If
Call
Berechne
End
Sub
Private
Sub
Bahn3_Exit(
ByVal
Cancel
As
MSForms.ReturnBoolean)
Dim
varWert
As
Variant
If
IsNumeric(Bahn3.Value)
Then
varWert = Bahn3.Value
Else
MsgBox strHinweis
Cancel =
True
Exit
Sub
End
If
If
varWert > 7
Then
MsgBox strFehler
Cancel =
True
Exit
Sub
End
If
If
varWert = 0
Then
MsgBox strWeiterSo
End
If
Call
Berechne
End
Sub
Private
Sub
Bahn4_Exit(
ByVal
Cancel
As
MSForms.ReturnBoolean)
Dim
varWert
As
Variant
If
IsNumeric(Bahn4.Value)
Then
varWert = Bahn4.Value
Else
MsgBox strHinweis
Cancel =
True
Exit
Sub
End
If
If
varWert > 7
Then
MsgBox strFehler
Cancel =
True
Exit
Sub
End
If
If
varWert = 0
Then
MsgBox strWeiterSo
End
If
Call
Berechne
End
Sub