bobmack37 Posted April 23, 2003 Posted April 23, 2003 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? Quote
*Experts* Nerseus Posted April 23, 2003 *Experts* Posted April 23, 2003 Try something like this: 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 Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.