Jump to content

Recommended Posts

Posted (edited)

I'm pretty much a noob with VB so bare with me please. I'm trying to write a Grocery Calculator program that uses the InputBox. I can't seem though to get it to work when formating it to Currency. You click on a button and it brings up the InputBox, you then enter an amount and press the OK button. This should then place the amount into the proper textbox and format it to currency. If anybody could help, I would much appreciate it.

Dim strInputBox As String

Dim decItemPrice As Decimal

strInputBox = InputBox("Enter item price", "Item Price")

decItemPrice = Convert.ToDecimal(strInputBox)

txtItemPrice.Text = FormatCurrency(decItemPrice)

Edited by footballking3420

Posted
Dim strInputBox As String

Dim decItemPrice As Decimal

strInputBox = InputBox("Enter item price", "Item Price")

decItemPrice = Convert.ToDecimal(strTextBox)

txtItemPrice.Text = FormatCurrency(decItemPrice)

Try changing the red highlighted text to be the same variable name.

Posted

That was just a typing error by me. They are the same variable name in the actual code. In the debugger after running the program, I get an error that states, "Input string was not in correct format" for decItemPrice = Convert.ToDecimal(strInputBox)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...