Moin o7,
Ich hab mir nur für Spaß mal zur Aufgabe gemacht VBA zu erlernen, und als Übung versuche ich momentan einen einfachen BMI Rechner zu schreiben.
Ansich klappt das auch ganz gut, ich hab was hingeschrieben, was meinem Wissen nach funktionieren sollte. Aber das tut es nicht. Ich bekomme beim compilieren die Fehlermeldung "Laufzeitfehler 424 - Objekt erforderlich".
Hier der Code soweit:
Private Sub CommandButton1_Click()
Dim age As Integer
Dim weight As Double
Dim size As Double
Dim bmi As Double
Dim agestr As String
Dim weightstr As String
Dim sizestr As String
Dim bmiint As Integer
agestr = TextBox1.Value
weightstr = TextBox2.Value
sizestr = TextBox3.Value
age = CInt(agestr)
weight = Val(weightstr)
size = Val(sizestr)
bmi = weight / (size * size)
bmiint = CInt(bmi)
If age > 19 Then
If OptionsButton1.Value = True Then
If (bmiint < 20) Then
MsgBox ("Sie haben Untergewicht!")
End If
If (19 < bmiint < 25) Then
MsgBox ("Sie haben Normalgewicht!")
End If
If (24 < bmiint < 30) Then
MsgBox ("Sie haben Übergewicht!")
End If
If (29 < bmiint < 40) Then
MsgBox ("Sie haben Adipositas!")
End If
If (bmiint > 39) Then
MsgBox ("Sie haben starke Adipositas!")
End If
End If
If OptionsButton2.Value = True Then
If (bmiint < 19) Then
MsgBox ("Sie haben Untergewicht!")
End If
If (18 < bmiint < 24) Then
MsgBox ("Sie haben Normalgewicht!")
End If
If (24 < bmiint < 30) Then
MsgBox ("Sie haben Übergewicht!")
End If
If (30 < bmiint < 40) Then
MsgBox ("Sie haben Adipositas!")
End If
If (bmiint > 39) Then
MsgBox ("Sie haben starke Adipositas!")
End If
End If
End If
If OptionsButton1.Value = True Then
If (bmiint < 15) Then
MsgBox ("Sie haben Untergewicht!")
End If
If (14 < bmiint < 22) Then
MsgBox ("Sie haben Normalgewicht!")
End If
If (21 < bmiint) Then
MsgBox ("Sie haben Übergewicht!")
End If
End If
If OptionsButton2.Value = True Then
If (bmiint < 17) Then
MsgBox ("Sie haben Untergewicht!")
End If
If (16 < bmiint < 22) Then
MsgBox ("Sie haben Normalgewicht!")
End If
If (21 < bmiint) Then
MsgBox ("Sie haben Übergewicht!")
End If
End If
End Sub
Die vom Debugger markierte Zeile habe ich hervorgehoben.
Hat jemand ne Idee woran das hängen könnte?
Vielen Dank im voraus,
Grüße
Sintho
|