Public Class Form1
Private Sub btnCompute_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim percent, calories As Double
Dim grams As Double
Dim allow_amount As Double = 30
grams = txtGrams.Text
calories = txtCalories.Text
percent = (grams * 9) / calories * 100
Dim fmtstr As String = "{0, 15}"
lstResult.Items.Clear()
lstResult.Items.Add(String.Format(fmtstr, txtFood.Text & " containts " & percent & _
"% calories from fat."))
If percent > allow_amount Then
lstResult.Items.Add(String.Format(fmtstr, txtFood.Text & " exceed the AHA recommendation."))
End If
End Sub
End Class
----------------------------------------------------------------------------
I would like the "Percent" result to come out as 37.50%