Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am able to write to a text file no problem. it store's it in the manner that i require:

 

14/12/2003 | 16:12 | HEARTS VERSUS HIBS

14/12/2003 | 16:12 | LAVINE SHOULD BE FORCED TO RESIGN

14/12/2003 | 16:12 | LAVINE SHOULD QUIT

 

 

When i open the text file to be read in a listbox they appear like so:

 

14/12/2003 | 16:12 | HEARTS VERSUS HIBS14/12/2003 | 16:12 | LAVINE SHOULD BE FORCED TO RESIGN 14/12/2003 | 16:12 | LAVINE SHOULD QUIT

 

it actually goes out of the listbox and I can only read a small amount instead of multiple lines.

 

 

my code is :

 

Dim H As New History

Dim a As AddCaller

Dim sr As New IO.StreamReader(New IO.FileStream(Application.StartupPath & "\Logs\Caller_history\" & TextBox4.Text & ".txt", IO.FileMode.OpenOrCreate))

Dim textfromfile As String = sr.ReadToEnd()

H.ListBox1.Items.Add(textfromfile)

sr.Close()

H.Visible = True

 

 

is this becuase i am only adding the text file as 1 item and not multiple? If so how do i go around doing multi line adding from a textbox? is it fairly straight forward.

 

Thanks

 

Chris

-----------------

It�s always funny until someone gets hurt� Then it become hilarious!

  • *Experts*
Posted

You can do it like this:

'read as long as there is anything to read from the file
Do While reader.Read()
  'use the read line method to read a line from the file
  ListBox1.Items.Add(reader.ReadLine())
Loop

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...