footballking3420 Posted November 30, 2007 Posted November 30, 2007 (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 StringDim decItemPrice As DecimalstrInputBox = InputBox("Enter item price", "Item Price")decItemPrice = Convert.ToDecimal(strInputBox)txtItemPrice.Text = FormatCurrency(decItemPrice) Edited November 30, 2007 by footballking3420
IcemanND Posted November 30, 2007 Posted November 30, 2007 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.
footballking3420 Posted November 30, 2007 Author Posted November 30, 2007 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)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now