Yves Mazzon Member Licensed User Longtime User Apr 27, 2015 #1 Hello group, I battling with an error "invalid double "" ". In my code I'm collecting 3 numerical values in 3 labels. The values in the labels are text type. when I compute them in a variable I get a message saying " An error has occurred in sub.java.lang.NumberFormatExeption: Invalid double: "" Then it ask me if I want to continue? If I say yes and fill the 3 boxes with a numerical value the error goes away Obviously if the label string is empty it does not compute. How can I get around that as my program will have to do a lot of math. see below the routine. Many thanks in advance Regards, Yves 'seconds computation hour = lblData5.Text minute = lblData6.Text second = lblData7.Text totalTimeSec = (hour *3600) + (minute*60) + second Display_results.Text = totalTimeSec
Hello group, I battling with an error "invalid double "" ". In my code I'm collecting 3 numerical values in 3 labels. The values in the labels are text type. when I compute them in a variable I get a message saying " An error has occurred in sub.java.lang.NumberFormatExeption: Invalid double: "" Then it ask me if I want to continue? If I say yes and fill the 3 boxes with a numerical value the error goes away Obviously if the label string is empty it does not compute. How can I get around that as my program will have to do a lot of math. see below the routine. Many thanks in advance Regards, Yves 'seconds computation hour = lblData5.Text minute = lblData6.Text second = lblData7.Text totalTimeSec = (hour *3600) + (minute*60) + second Display_results.Text = totalTimeSec
eurojam Well-Known Member Licensed User Longtime User Apr 27, 2015 #2 Yves, not the seconds computation is the problem, the problem is what event starts your seconds computation. In other words you have to check if there are values which can be converted to double like: Code: If IsNumber(lblData5.Text) and IsNumber(lblData6.Text) and IsNumber(lblData7.Text) then hour = lblData5.Text minute = lblData6.Text second = lblData7.Text totalTimeSec = (hour *3600) + (minute*60) + second Display_results.Text = totalTimeSec end if stefan Upvote 0
Yves, not the seconds computation is the problem, the problem is what event starts your seconds computation. In other words you have to check if there are values which can be converted to double like: Code: If IsNumber(lblData5.Text) and IsNumber(lblData6.Text) and IsNumber(lblData7.Text) then hour = lblData5.Text minute = lblData6.Text second = lblData7.Text totalTimeSec = (hour *3600) + (minute*60) + second Display_results.Text = totalTimeSec end if stefan
Yves Mazzon Member Licensed User Longtime User Apr 27, 2015 #3 Many thanks Stefan, that did the trick. Yves Upvote 0