Link to home
Start Free TrialLog in
Avatar of seldeby
seldeby

asked on

save to textfile and get values from textfile to a listbox (vb.net)

Hi

I wounder how i would do if i want to save text from a textbox to file?
And how would i do if i want this from textfile to listbox.

/stefan
Avatar of Timbo87
Timbo87

I'm not quite sure what you mean by saving a "textfile to listbox", but here's how you would save a textbox to a file:

Imports System.IO

Dim f as StreamWriter = New StreamWriter("C:\temp\file.txt")
f.Write(textBox1.Text)
f.Close()
Avatar of seldeby

ASKER

i'm getting an error on Imports.
It says that statements must precede any declarations.
what does that mean?
Imports System.IO goes on the absolute first line above all other code. The rest of the code goes in your module.
Avatar of seldeby

ASKER

It working.
But when i'm adding it delete the old value.
How will i do so it just adds the new value after the old?


About listbox:

I want to get that are in the text to the listbox.
So the listbox will get all the values that are  in the text file.
ASKER CERTIFIED SOLUTION
Avatar of Timbo87
Timbo87

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial