Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I cant get this to work, i really need help. i want to a fomula n x 35 = labor then n x 5% = cost and labor + cost = total. i really need help. Im a beginner in this, so if you have the time, can you help me. thnx!

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim rate, sale, labor, total, cost As Double

With lstResults.Items

rate = 35

sale = 0.05

total = labor + cost

.Clear()

.Add(labor = CDbl(TextBox2.Text * rate))

.Add(cost = CDbl(TextBox3.Text * sale))

.Add(total = CDbl(labor + cost))

End With

 

End Sub

  • *Experts*
Posted

What do you need help with, errors the formula?

Right now I can tell you that you are trying to muliply a string value from the textbox with a double which is not possible.

Also the variable total is not needed bcause you are not using it.

Posted

ok im an idiot, wasnt think. here is the fix up of it. now i wanna know is that how do i list my currency right align on the listbox? i having trouble with formatting output with zones

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim rate, sale, labor, total, cost As Double

Dim fmtstr As String = "{0,-20}{1,-40:C}"

lstResults.Items.Clear()

Name = TextBox1.Text

rate = 35

sale = 0.05

labor = CDbl(TextBox2.Text * rate)

cost = CDbl(TextBox3.Text * sale) + CDbl(TextBox3.Text)

total = CDbl(labor + cost)

With lstResults.Items

.Add(String.Format(fmtstr, "Customer", (Name)))

.Add(String.Format(fmtstr, "Labor Cost", (Math.Round(labor))))

.Add(String.Format(fmtstr, "Parts Cost", (Math.Round(cost))))

.Add(String.Format(fmtstr, "Total Cost", (Math.Round(total))))

 

End With

End Sub

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...