Hi.
I am experiencing a strange "bug". I get the following error, when trying to put a string value, just read with a TextReader, to an integer (or double) variable:
java.lang.NumberFormatException: Invalid double: "5"
The code is:
The same doesn't happen if i force the string value to : sz="5", for example.
What am I missing? Thanks in advance.
I am experiencing a strange "bug". I get the following error, when trying to put a string value, just read with a TextReader, to an integer (or double) variable:
java.lang.NumberFormatException: Invalid double: "5"
The code is:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim N As Int
Dim D As Double
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
If FirstTime=True Then
Dim NomeFileLocale As String : NomeFileLocale="Smas/ListaCaixaN_UTF8.txt"
If File.Exists(File.DirRootExternal, NomeFileLocale) Then
Dim TextReader1 As TextReader
TextReader1.Initialize2(File.OpenInput(File.DirRootExternal, NomeFileLocale),"UTF8")
Dim sz As String
sz = TextReader1.ReadLine.Trim ' this reads "5"
D=sz ' <<< error HERE (originally I need an integer variable
N=sz ' but I try also with a double, and see that doesn't depend on Integer or double)
TextReader1.Close
End If
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
What am I missing? Thanks in advance.