J jnbarban Member Licensed User Longtime User May 19, 2011 #1 Do you Know how to do that : B4X: if MyTextBox.text > 0 then ... end if ( MyTextBox.text = "1234") i've got this error : " NumberFormatException" It is not possible to do somthing like cint(MyTextBox.text) in order to get me a Integer of my text value ?
Do you Know how to do that : B4X: if MyTextBox.text > 0 then ... end if ( MyTextBox.text = "1234") i've got this error : " NumberFormatException" It is not possible to do somthing like cint(MyTextBox.text) in order to get me a Integer of my text value ?
Erel B4X founder Staff member Licensed User Longtime User May 19, 2011 #2 Your code should work, assuming that the string is indeed a number. Make sure that there are no extra spaces in the string. You can use IsNumber to check if the string can be parsed as a number. Upvote 0
Your code should work, assuming that the string is indeed a number. Make sure that there are no extra spaces in the string. You can use IsNumber to check if the string can be parsed as a number.
vangogh Active Member Licensed User Longtime User May 19, 2011 #4 to "bypass" a null string, I always use "0" & MyTextBox.text > 0 so it the textbox is empty, this gives "0" & "" = 0 if it is "1234" -> "01234" > 0 it works :sign0137: Upvote 0
to "bypass" a null string, I always use "0" & MyTextBox.text > 0 so it the textbox is empty, this gives "0" & "" = 0 if it is "1234" -> "01234" > 0 it works :sign0137:
fabero Member Licensed User Longtime User May 20, 2011 #5 vangogh said: to "bypass" a null string, I always use "0" & MyTextBox.text > 0 so it the textbox is empty, this gives "0" & "" = 0 if it is "1234" -> "01234" > 0 it works :sign0137: Click to expand... Can someone explain more a bit? I've the same problem.. :BangHead::BangHead: Upvote 0
vangogh said: to "bypass" a null string, I always use "0" & MyTextBox.text > 0 so it the textbox is empty, this gives "0" & "" = 0 if it is "1234" -> "01234" > 0 it works :sign0137: Click to expand... Can someone explain more a bit? I've the same problem.. :BangHead::BangHead:
vangogh Active Member Licensed User Longtime User May 22, 2011 #6 simply use the debugger and try my suggestion step by step... it works my post isn't a problem but a workaround :sign0060: Upvote 0
simply use the debugger and try my suggestion step by step... it works my post isn't a problem but a workaround :sign0060:
NeoTechni Well-Known Member Licensed User Longtime User May 22, 2011 #7 fabero said: Can someone explain more a bit? I've the same problem.. :BangHead::BangHead: Click to expand... Let's say the user enters nothing in the text box Since you're checking 0 & textbox.text, it will read "0" which is a number, instead of crashing. You can also just use IsNumber () to check if it's valid first Last edited: May 22, 2011 Upvote 0
fabero said: Can someone explain more a bit? I've the same problem.. :BangHead::BangHead: Click to expand... Let's say the user enters nothing in the text box Since you're checking 0 & textbox.text, it will read "0" which is a number, instead of crashing. You can also just use IsNumber () to check if it's valid first