display file

eec

New member
Joined
Feb 18, 2005
Messages
3
Programming Experience
Beginner
it was working before but now it will not load the file. i don't get a msgbox so i know it finds the file but it will not display in the lstbox

Private Sub btndisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndisplay.Click

Dim objstreamreader As System.io.StreamReader

Dim strfilename As String

Dim intloop As Integer

Dim pintrecordcounter As Integer

lstfilecontents.Items.Clear()

strfilename = txtfilename.Text

If System.IO.File.Exists(strfilename) = False Then _

MsgBox("File not Found")

Exit Sub

objstreamreader = System.IO.File.OpenText(strfilename)

Do Until objstreamreader.Peek = -1

pstrline(pintrecordcounter) = objstreamreader.ReadLine

pintrecordcounter += 1

Loop

objstreamreader.Close()

Do Until intloop >= pintrecordcounter

Loop

lstfilecontents.Items.Add(pstrline(intloop))

End Sub

 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
VB.NET:
[size=2][color=#0000ff]Do[/color][/size][size=2][color=#0000ff]Until[/color][/size][size=2] intloop >= pintrecordcounter

[/size][size=2][color=#0000ff]Loop

[/color][/size][size=2]lstfilecontents.Items.Add(pstrline(intloop))
you need to move the "[/size]lstfilecontents.Items.Add(pstrline(intloop))" line so it's inside that loop IE:

VB.NET:
[/size][size=2][color=#0000ff]Do[/color][/size][size=2][color=#0000ff]Until[/color][/size][size=2] intloop >= pintrecordcounter
    [/size][size=2]lstfilecontents.Items.Add(pstrline(intloop))

[/size][size=2] [/size][size=2][color=#0000ff]Loop
[/color]
 
Top Bottom