Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

***************a part of the source code*****************

Dim file As New System.IO.StreamWriter(filename)

 

For i = 0 To UBound(sFiles)

file.WriteLine(sFiles(i))

Next

file.Close()

ListBox1.Items.Clear()

ListBox1.Items.Add("The text file is written in the same directory as this executable, as " & filename)

btnSave.Enabled = False

btnShowFiles.Text = "Show Directory Files"

btnShowFiles.Focus()

ListBox1.Items.Add(Application.StartupPath & "\" & filename)

Catch ArgumentExep As System.ArgumentException

MsgBox(ArgumentExep.Message & vbLf & "Don't use illegal characters," & vbLf & "and wait 5 to 10 seconds to save to another file.")

Catch IOExep As System.IO.IOException

MsgBox(IOExep.Message & vbLf & "Wait 5 to 10 seconds and then save again, with another filename.")

End Try

 

I need the program to writes all the lines in the listbox to the .txt and not only the result. Maybe one of u guys have a solution for it.

  • Administrators
Posted

what is the variable sFiles? Is that being written to a file for a reason?

If you want to save and load items from a ListBox why are you clearing it and adding non-listbox information to it?

 

You should be able to save the list with code similar to

Dim ListFile as new System.IO.StreamWriter("Random file name here.txt")

Dim i as string
for each i in listbox1.items
    listfile.writeline(i)
next
listfile.close()

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

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...