FoSsiL Posted November 2, 2003 Posted November 2, 2003 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 Quote
*Experts* mutant Posted November 2, 2003 *Experts* Posted November 2, 2003 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. Quote
FoSsiL Posted November 2, 2003 Author Posted November 2, 2003 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 Quote
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.