You are not logged in.

fallon416

Beginner

  • "fallon416" started this thread

Posts: 28

Date of registration: Mar 26th 2010

  • Send private message

1

Friday, March 26th 2010, 7:26pm

populate listbox from text file

Hi,

I'm trying to populate a ListBox from a text file but I'm having a problem with the while loop. I looked at the Java IO code and am trying to use it with the common dialog. For some reason the Java IO doesn't like the While loop added to it. Here is the code that I'm trying to use. I'm not a Java developer so I really don't have a clue. If I take out the While loop the first item in the text file is loaded.

CommonDialog1.Filter = "Playlist files (*.plf)|*.plf|" & "All files|*.*"
CommonDialog1.ShowOpen

Dim FChnl As java#io#FileInputStream
Dim FGet As java#io#DataInputStream
Dim Text() As Byte

FChnl = New FileInputStream(CommonDialog1.FileName)

FGet = New DataInputStream(FChnl)

Redim Text(0 To CommonDialog1.FileName.length - 1)

FGet.readFully(Text)
While Text <> ""
lstPlaylist.AddItem New ListCellData(StrConv(Text, vbUnicode))
End While
FChnl.close

fallon416

Beginner

  • "fallon416" started this thread

Posts: 28

Date of registration: Mar 26th 2010

  • Send private message

2

Friday, March 26th 2010, 8:09pm

I found some sample code in one of the forums that worked great. Problem solved.

CommonDialog1.Filter = "Playlist files (*.plf)|*.plf|" & "All files|*.*"
CommonDialog1.ShowOpen


Dim FF As VBFileHandler
Dim LineText As String
FF = Open(CommonDialog1.FileName)
Do Until FF.EOF
LineText = ReadLine(FF)
lstPlaylist.AddItem New ListCellData(LineText)
Loop
FF.close()

Rate this thread
WoltLab Burning Board