Private sub btnCompute_click () handles btnCompute.click

Dim Total, labor, customer As String

labor = cdbl(txthour.text * 35)
parts = cdbl(txtpart.text + 5%)
Total = labor + parts
customer = txtname.text
lstResult.Items.add.clear()
lstResult.Items.add("customer" & customer)
lstResult.Items.add("Labor cost" & Labor)
lstResult.Items.add("Parts Cost" & Parts)
lstResult.Items.add(" Total Cost" & Total)

end sub

*******************************************
THANKS IN ADVANCE

Recommended Answers

All 5 Replies

5% doesn't mean anything in code.

If i may ask
What you i enter when trying to put a Percent sign?

Thank you

What value does 5% represent?

Hint: it's between 0 and 1.0

>Can someone see anything wrong ?

Line #1 ...

Hi

I think this is how i would write it:

Dim customer As String
Dim TOTAL, parts, labor As Double

        labor = CDbl(Txthour.Text * 35)
        parts = CDbl(Txtpart.Text + 5)
        Total = labor + parts
        customer = txtname.text
        lstResult.Items.Clear()
        lstResult.Items.add("customer" & customer)
        lstResult.Items.add("Labor cost" & labor)
        lstResult.Items.add("Parts Cost" & Parts)
        lstResult.Items.add(" Total Cost" & Total)

I think the variables: Total,Parts and Labor should be Double type.
A string type would concatenate the values Labor + Parts instead of adding them.


Also you cant add and clear a listitem in the same command.
lstResult.Items.Clear()
I hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.