I need to read a text file which holds an integer number (in this case '6').
How can I read this value into a variable?
Everything I try keeps coming up with that annoying and pointless error message "numberformatexception".
I have tried using a textreader in readline mode but without luck....
dim TR as TextReader
dim xsize as string
dim sdcard_folder as string: sdcard_folder = "testfolder"
TR.Initialize(File.OpenInput(File.DirRootExternal, sdcard_folder & "xsize.txt"))
xsize = TR.ReadLine
If IsNumber(xsize) = False Then 'DIDN'T READ THE VALUE
TR.Close
When running this code the value of '6', found in the text file, should be read into the string variable 'size'. But it isn't and the if-then test for a number fails. Why isn't the number read as the first line of a text file?
(I have simplified this code for ease of reading)
How can I read this value into a variable?
Everything I try keeps coming up with that annoying and pointless error message "numberformatexception".
I have tried using a textreader in readline mode but without luck....
dim TR as TextReader
dim xsize as string
dim sdcard_folder as string: sdcard_folder = "testfolder"
TR.Initialize(File.OpenInput(File.DirRootExternal, sdcard_folder & "xsize.txt"))
xsize = TR.ReadLine
If IsNumber(xsize) = False Then 'DIDN'T READ THE VALUE
TR.Close
When running this code the value of '6', found in the text file, should be read into the string variable 'size'. But it isn't and the if-then test for a number fails. Why isn't the number read as the first line of a text file?
(I have simplified this code for ease of reading)
Last edited: