I want to get the first line "123456789" as a string.
And similarly , i want to get the second line "abcdefghijk" as another string.
And the same way , i want to get the 3th line "zzzzzzz" as another string.
Sub ReadTextReader
Dim TextReader1 As TextReader
TextReader1.Initialize(File.OpenInput(File.DirRootExternal, "Text.txt"))
Dim line As String
line = TextReader1.ReadLine
Do While line <> Null
Log(line) 'write the line to LogCat
line = TextReader1.ReadLine
Loop
TextReader1.Close
End Sub
Dim txtlist As List = File.ReadList(File.DirAssets,"filetoread.txt")
Dim str1 As String = txtlist.Get(0) ' Get 1st line
Dim str2 As String = txtlist.Get(1) ' Get 2nd line
Dim txtlist As List = File.ReadList(File.DirAssets,"filetoread.txt")
Dim str1 As String = txtlist.Get(0) ' Get 1st line
Dim str2 As String = txtlist.Get(1) ' Get 2nd line
Putting a positive spin on it: now you have a choice of two solutions:
1/ Marco's suggestion will give you sequential (one-at-a-time) access to an unlimited number of lines
2/ Manfred's suggestion will give you random (direct, and in any order) access to a limited number of lines
and can use whichever works best for this particular task.
The given Sub is ideal example. Because it is even possible to add textual content to The texts of A GUI widgets with no need to manually add 30 or 40 textual descriptions for every GUI widget inside source code or by using GUI designer. Thank you for this perfect SUB. I will be finally able to automatize my verbal based tests for memory training. So very well done, perfect sub and sub even detect if The end of text file have been reached. Really. I have never found so ammazing programmers community like here is.