I need some help with this calculate code.

bobmack37

Newcomer
Joined
Apr 22, 2003
Messages
12
Dim vbill As Single
Dim vPtip As Single
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
vbill = 20
vPtip = 15%
txtData.Text = vbill * vPtip

End Sub
End Class

I am trying to write a program to calculate the amount of a waiter's tip given the amount of the bill and the percentage tip obtained via input dialog boxes. I would like the output to be a complete sentence that reiterates the inputs and gives the resulting tip something like this "A 15.00% tip on $20.00 is $3.00." This one I am doing to pactice off for code I would lie to write that is somewhat the same. Can anyone help me with this one and let me know how I am doing so far?
 
Try something like this:
Visual Basic:
        Dim vbill As Single = 20
        Dim vPtip As Single = 0.15
        TextBox1.Text = String.Format("A {0} tip on {1} is {2}", vPtip.ToString("0.00%"), vbill.ToString("c"), (vPtip * vbill).ToString("c"))

-Nerseus
 
Back
Top