Hello:
If I have a string set to "" (Null) or Empty why does the application crash if I try and assign it to an int
Why isn't a null string or a string with just spaces handled as a Zero?
Before the gang wagon jumps on, let me explain my reasoning.
MOST of the time I do not want a Zero to be displayed. So I have to set the input field as "" so nothing shows.
Now every time I need to do something with the value I need to check to see if the length is zero
I am not a basic programmer, but I would have thought basic would treat a null string or a string containing only spaces as a Zero.
To me this seems only logical, but I am sure someone has a reason for this?
Is there a way to not show a Zero in an input field but have a zero there or have a null or space there and not have the program crash on assigning it to an INT variable. As I am typing this I guess I just answered my own question. I guess I need to write a _atol function and always us that for assignment's instead of INT = <Field>.text
Just wondering why Basic4Android doesn't do this for me when casing from text to numeric
Thanks
BobVal
If I have a string set to "" (Null) or Empty why does the application crash if I try and assign it to an int
B4X:
Dim TestString as String
Dim TestCount as Int
TestString = "" ' Set as Empty String
TestCount = TestString ' This instruction will fail because the string is Null and I get invalid double
Why isn't a null string or a string with just spaces handled as a Zero?
Before the gang wagon jumps on, let me explain my reasoning.
MOST of the time I do not want a Zero to be displayed. So I have to set the input field as "" so nothing shows.
Now every time I need to do something with the value I need to check to see if the length is zero
I am not a basic programmer, but I would have thought basic would treat a null string or a string containing only spaces as a Zero.
To me this seems only logical, but I am sure someone has a reason for this?
Is there a way to not show a Zero in an input field but have a zero there or have a null or space there and not have the program crash on assigning it to an INT variable. As I am typing this I guess I just answered my own question. I guess I need to write a _atol function and always us that for assignment's instead of INT = <Field>.text
Just wondering why Basic4Android doesn't do this for me when casing from text to numeric
Thanks
BobVal