November 30, 200718 yr 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 StringDim decItemPrice As DecimalstrInputBox = InputBox("Enter item price", "Item Price")decItemPrice = Convert.ToDecimal(strInputBox)txtItemPrice.Text = FormatCurrency(decItemPrice) Edited November 30, 200718 yr by footballking3420
November 30, 200718 yr Dim strInputBox As StringDim decItemPrice As DecimalstrInputBox = 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.
November 30, 200718 yr Author 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