Need Help in VB.Net 2003

FoSsiL

Newcomer
Joined
Nov 2, 2003
Messages
2
Location
Brooklyn, NyC
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
 
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.
 
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
 
Back
Top