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.

Whats wrong with vb.net program?

Please don't do it for me just point me in the right direction. Its for class and i don't want to cheat. I cant get in touch with my instructor.

'Declare variable and constant

Dim decWeight As Decimal = 0 'txtweight as variable Decimal

Dim decDistance As Decimal = 0 'txtDistance as variable Decimal

Dim decTotal As Decimal = 0 'lblTotal as variable Decimal

Const decShipOne = 0.01 'shipping rate one as constant

Const decShipTwo = 0.015 'Shipping rate two as constant

Const decShipThree = 0.02 'shipping rate three as constant

Const decShipFour = 0.025 'shipping rate four as constant

'Range Checking

decWeight = CDec(txtWeight.Text)

If decWeight < 0 Or decWeight > 20 Then

MessageBox.Show("Please enter numeric values between 0 and 20")

End If

decDistance = CDec(txtWeight.Text)

If decDistance < 10 And decDistance > 3000 Then

MessageBox.Show("Enter distance between 10 and 3000")

End If

'Convert txtDistance

decDistance = CDec(txtDistance.Text)

'Calculate Shipping :,(

If decWeight < 2 Then

decWeight = decShipOne And decShipOne * decDistance = decTotal

End If

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

Update:

Sspade that was exactly what i was trying to do thank you!

3 Answers

Relevance
  • 9 years ago
    Favorite Answer

    There are a few logical errors in there, but the syntax error you will hit is on this line:

    decWeight = decShipOne And decShipOne * decDistance = decTotal

    Notice that you have two "=" (assignment operators). I'm not sure what you are trying to do, but to set "decTotal", then decTotal should be on the left. I also suspect "AND" is not what you want there, since it appears to be a mathematical calculation. I suggest using + instead.

    I see some other errors earlier (using the wrong variable and using the wrong logical operator), but maybe you can find those.

  • Anonymous
    4 years ago

    seem at Social secure practices and Medicare/Medicaid. All are having money issues and could require extra government investment (larger taxes). Police hearth,EMT's,instructors are interior of reach or state. Ola: the publish place of work might make a earnings each 12 months IF it did not ought to coach its sales over to congress and then ought to ask for the money to function.

  • 9 years ago

    I think it might be this statement:

    decWeight = decShipOne And decShipOne * decDistance = decTotal

    What about using '+' instead of 'And'? And the two equals in one statement?

Still have questions? Get your answers by asking now.