Hi Everyone,
I am working on an app that needs to copy a text file from a network server to the device, and then display the file in spinner view or a list view. This is the code that I think should work, but does not:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("TestLayout") 'load the screen layout
If FirstTime Then
SMB1.Initialize("SMB1") 'load the SMB File library
End If
'Load the data file path to the network server
If File.Exists(File.DirInternal,"URLPath.txt") Then
URLServer = File.ReadString(File.DirInternal,"URLPath.txt")
Else
Msgbox("Setups are not complete.","Complete Setups")
End If
'load the department file from network server
SMB1.DownloadFile("smb:" & URLServer ,"tabdep.txt", File.DirInternal,"tabdep.txt") 'load department file
'problem code below?
Dim reader As TextReader
Dim Dline As String
reader.Initialize(File.OpenInput(File.DirInternal,"tabdep.txt"))
Dline = reader.ReadLine
DepSpinner.AddAll(Regex.Split(",",Dline))
End Sub
The section labeled "problem code below?" works fine if it is placed under a button somewhere on the layout that the user taps. The spinner control displays the items correctly. When the code is inserted as above, the application appears briefly on the tablet device, then disappears. I'm connected to an Android tablet using the Bridge wireless option (which seems to work very well).
Any ideas where I'm going wrong? I'm a very experienced VB6 programmer, but this has me a little lost.