Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...