Problems converting numbers from strings

Stulish

Active Member
Licensed User
Longtime User
Hi,

My app transfers data via serial communications, the data is in a string format.

my app seems to run ok but at times it will sometimes throw up and invalid double error, this normally happens if some of the sentances have not been sent and the the fields are blank.


My understanding was if i have a string that contains "00.03" in a variable SomeString

and then i create a variable SomeDouble by:

B4X:
Dim SomeDouble as double

when i use the following it should convert the string to a double automatically:

B4X:
SomeDouble = SomeString

is this thinking correct?

what is the outcome if the string contains nothing?

i have tried to catch the error using an if statement to say

B4X:
if SomeString<>"" then SomeDouble=SomeString
basically if the string contains nothing then do not do the conversion, but i still get the error


nothing seems to work
 

eps

Expert
Licensed User
Longtime User
Internal can be external... It's a bit of a contradiction, it's more that the directory is internal to your App. If you are writing files for your App do something like this :

B4X:
    TextWriteLine.Initialize(File.OpenOutput(File.DirInternal, "refresh_setting.txt", False))

DirInternal can be internal or external storage, but if you use DirInternal it will always work and it won't actually matter where it's stored, the App will know.

HTH - any more questions please start a new thread.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…