cookiemonster
New member
- Joined
- Apr 29, 2009
- Messages
- 3
- Programming Experience
- Beginner
I'm takeing a vb class in my college and need a a little help here is the my problem is that when i run the program if i put Calories as 200 and fat as any thing grater than 2
executes so if i put somehthing like calories = 200 fat = 8 i get he message i was sjut wondering what i did wrong
VB.NET:
If txtCalories.Text < txtFat.Text Then
MessageBox.Show("Grams of fat cannot be greater than total calories please check your data and try again")
executes so if i put somehthing like calories = 200 fat = 8 i get he message i was sjut wondering what i did wrong
VB.NET:
Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
'==================================================='
' Calculate the percentage useing the given amounts '
'==================================================='
Dim dblPercent_From_Fat As Double
'==================================================='
Try
If txtCalories.Text < txtFat.Text Then
MessageBox.Show("Grams of fat cannot be greater than total calories please check your data and try again")
If CDbl(txtFat.Text) < 0 Then
MessageBox.Show("Grams of Fat Cannot be less than 0 please check your informationa and try again")
End If
If CDbl(txtCalories.Text) < 0 Then
MessageBox.Show("Calories Cannot be less than 0 please check your Information and try again")
End If
Else
dblPercent_From_Fat = CDbl(txtFat.Text) * CDbl(9) / _
CDbl(txtCalories.Text)
lblPercent_of_Fat.Text = dblPercent_From_Fat.ToString("p")
End If
Catch ex As Exception
MessageBox.Show("Must Be Calculated as Numbers", _
"Error")
End Try
End Sub