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
3
Me
.Controls(
"Bahn"
& n).Value = 0
Next
n
End
Sub
Private
Sub
Bahn1_Change()
If
Len(Bahn1.Text) = 0
Then
MsgBox strHinweis
Exit
Sub
End
If
If
Val(Bahn1.Text) = 0
Then
MsgBox strWeiterSo
End
If
If
Bahn1 > 7
Then
MsgBox strFehler
End
If
Call
Berechne
End
Sub
Private
Sub
Bahn2_Change()
If
Len(Bahn2.Text) = 0
Then
MsgBox strHinweis
Exit
Sub
End
If
If
Val(Bahn2.Text) = 0
Then
MsgBox
"Mach weiter so, dann schaffst du die Bahnen unter 18."
End
If
If
Bahn2 > 7
Then
MsgBox
"Du hast nur 6 Schläge!"
End
If
Call
Berechne
End
Sub
Private
Sub
Bahn3_Change()
If
Len(Bahn3.Text) = 0
Then
MsgBox strHinweis
Exit
Sub
End
If
If
Val(Bahn3.Text) = 0
Then
MsgBox
"Mach weiter so, dann schaffst du die Bahnen unter 18."
End
If
If
Bahn3 > 7
Then
MsgBox
"Du hast nur 6 Schläge!"
End
If
Call
Berechne
End
Sub
Private
Sub
Berechne()
Dim
n
As
Integer
For
n = 1
To
3
Me
.Controls(
"Textbox"
& n).Text = 0
Next
n
For
n = 1
To
3
If
Me
.Controls(
"Bahn"
& n).Value = 1
Then
Textbox1.Text = Textbox1.Text + 1
End
If
If
Me
.Controls(
"Bahn"
& n).Value > 2
Then
Textbox2.Text = Textbox2.Text - 2
End
If
Next
n
Textbox3.Text = Val(Bahn1.Text) + Val(Bahn2.Text) + Val(Bahn3.Text)
End
Sub