Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

vb.net help i have a problem with my school program?

for some reason the decParts and decTax(on parts) wont display, it says they cant convert to label because they are strings even tho i used Cdec to convert them.

also i need to use a function and sub procedure in this program how would you suggest i do that?

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

'declare variables

Dim decOil As Decimal

Dim decFlush As Decimal

Dim decMisc As Decimal

Dim decPart As Decimal

Dim decLabor As Decimal

Dim decPartLabor As Decimal

Dim decTotal As Decimal

Dim decSandL As Decimal

Dim decTax As Decimal

'gets amount for oil change

If chkOil.Checked = True Then

decOil += 26.0

End If

If chkLube.Checked = True Then

decOil += 18.0

End If

'gets amount for flushes

If chkTransmission.Checked = True Then

decFlush += 80.0

End If

If chkRadiator.Checked = True Then

decFlush += 30.0

End If

'gets AMOUNT for misc services

If chkInspection.Checked = True Then

decMisc += 15.0

End If

If chkMuffler.Checked = True Then

decMisc = 100.0

End If

If chkTire.Checked = True Then

decMisc += 20.0

End If

'get amount for parts and labor

decLabor = CDec(txtLabor.Text)

decPart = CDec(txtParts.Text)

decPartLabor = decPart + decLabor

'Gets amount for service and labor

decSandL = decOil + decFlush + decMisc + decFlush + decLabor

'get amount for total

decTotal = decOil + decFlush + decMisc + decFlush + decPartLabor

'get amount for tax

decTax = decPart * 0.06

'display parts

lblParts = decPart.ToString("C")

'display tax

lblTax = decTax.ToString("C")

'display service and labor

lblSAndL.Text = decSandL.ToString("C")

'display total

lblTotal.Text = decTotal.ToString("C")

End Sub

Update:

Okay i fixed that, and i feel dumb, but now its saying "decLabor = CDec(txtLabor.Text)" cannot be converted to a decimal

2 Answers

Relevance
  • 9 years ago
    Favorite Answer

    You wrote:

    lblParts = decPart.ToString("C")

    'display tax

    lblTax = decTax.ToString("C")

    It should be:

    lblParts.Text = decPart.ToString("C")

    'display tax

    lblTax.Text = decTax.ToString("C")

    Source(s): VB.NET Programmer
  • 9 years ago

    Try adding .ToString after it.

Still have questions? Get your answers by asking now.