I am BRAND new to programming so please be gentle
I have been working on a calculator of sorts and things are finally progressing but I am encountering two errors that I cannot figure out.
1. If I run the calculator and I fill in both of the text boxes (listing price and sales price) then no errors are encountered, however, if I do not fill in one of the textboxes with a value then I receive:
"An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format."
With the error directing to which ever textbox value was left blank. It also says that the code has called into another function and when that function is finished, this is the next function that will be executed.
Here is the code for converting the two text boxes:
VB Code:
Public Function ListFees() As Double ' Compute the initial ebay listing fee ' based on the listing price of the item listprice = Double.Parse(TextBox1.Text) 'convert input string to number Select Case listprice Case 0.0 list = 0.0 Case 0.01 To 0.99 list = 0.25 Case 1 To 9.99 list = (0.35) Case 10 To 49.99 list = (0.6) Case 50 To 199.99 list = 2.4 Case 200 To 499.99 list = 3.6 Case Is >= 500 list = 4.8 End Select End Function Function FinalValue() As Double ' compute final value fee ' based on the sales price sellprice = Double.Parse(TextBox2.Text) Select Case sellprice Case 0 To 25 fvfee = (sellprice * 0.0525) Case 25.01 To 1000 fvfee = (sellprice - 25) * 0.0275 + 1.31 Case Is > 1000 fvfee = (sellprice - 1000) * 0.015 + 28.12 End Select End Function
All variables have previously been declared as Double
2. The second problem is that when the program does run correctly, the decimals are all out of whack. I want all numbers to appear in a currency type of format (two places afer the decimal) but I am getting three or four, unless the second character is a zero, then I only get one digit after the decimal. I am sure I am missing a conversion or something?
Thanks in advance for any help




Reply With Quote