Blubb1337 (02-24-2010),hopefordope (02-25-2010),Lyoto Machida (02-16-2011),Tunguestenio (03-27-2011),XGelite (02-24-2010),___x][GooD. (01-20-2011)
Ok guys so heres a short simple tutorial on how to Save/Load a listbox and its contents.
1. Add a listbox to a form(obviously)
2. Now under public class form 1 add this:
3. Now to save a listbox contents use this code:Code:Inherits System.Windows.Forms.Form Dim w As IO.StreamWriter Dim r As IO.StreamReader
4. Now to load a listbox contents.Code:Dim i As Integer w = New IO.StreamWriter(Save Location Here. Save as .txt file) For i = 0 To ListBox1.Items.Count - 1 w.WriteLine(ListBox1.Items.Item(i)) Next w.Close()
Its as simple as that.Code:r = New IO.StreamReader("Load location here. must load from .txt file) While (r.Peek() > -1) ListBox1.Items.Add(r.ReadLine) End While r.Close()
Now for a side note: You must save a listbox contents to a .txt file before you can load them. Also the save location should be as same as the save location.
Now the entire code put together:
Code:Public Class Form1 Inherits System.Windows.Forms.Form Dim w As IO.StreamWriter Dim r As IO.StreamReader Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer w = New IO.StreamWriter("c:\test.txt") For i = 0 To ListBox1.Items.Count - 1 w.WriteLine(ListBox1.Items.Item(i)) Next w.Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click r = New IO.StreamReader("c:\test.txt") While (r.Peek() > -1) ListBox1.Items.Add(r.ReadLine) End While r.Close() End Sub End Class
Last edited by Bombsaway707; 02-23-2010 at 09:43 PM.
Blubb1337 (02-24-2010),hopefordope (02-25-2010),Lyoto Machida (02-16-2011),Tunguestenio (03-27-2011),XGelite (02-24-2010),___x][GooD. (01-20-2011)
Looks Good , Thank you
NextGen1 (02-23-2010)
Sorry if i bumped this but i hav a question
can u do this same with a txt box
Press Thank You[IMG]https://i45.tinypic.com/2hg8w0n.jpghttps://img1.UploadScreensho*****m/images/main/2/3203234450.jpg[/IMG]
My Releases
Injector 3G
Injector 2G
Injector 1G
Super Spammer
CA Cleaner
My Tutorials
How to Make a real Injector(PerX)
How to Make a Calculator(leeched)
so would this work for .xml files as well?
Great tutorial!
-Rest in peace leechers-
Your PM box is 100% full.
so what would it be if i wanted to save it to the desktop
w = New IO.StreamWriter(Save Location Here. Save as .txt file)
Press Thank You[IMG]https://i45.tinypic.com/2hg8w0n.jpghttps://img1.UploadScreensho*****m/images/main/2/3203234450.jpg[/IMG]
My Releases
Injector 3G
Injector 2G
Injector 1G
Super Spammer
CA Cleaner
My Tutorials
How to Make a real Injector(PerX)
How to Make a Calculator(leeched)
"C:\Documents and Settings\User\USERNAME
\Desktop\"
so.....
You can use the codeCode:w = New IO.StreamWriter("C:\Documents and Settings\User\USERNAME \Desktop\sample.txt")
to get the usernameCode:Enviroment.Username
so to save to anyones desktop
Code:dim usern as enviroment.username w = New IO.StreamWriter("C:\Documents and Settings\User\" & usern & "\Desktop\sample.txt")
Last edited by NextGen1; 02-25-2010 at 10:57 PM.
hopefordope (02-25-2010)
Hehehe good job, great tut
it says that Type'Environment.username' is not defined..... i tryed the usern = blalalal method but it still didnt work this is my [php]Dim i As Integer
Dim usern As Environment.Username
w = New IO.StreamWriter("C:\Documents and Settings\User\" & usern & "\Desktop\sample.txt")
For i = 0 To Dlls.Items.Count - 1
w.WriteLine(Dlls.Items.Item(i))
Next
w.Close()[/php]
Press Thank You[IMG]https://i45.tinypic.com/2hg8w0n.jpghttps://img1.UploadScreensho*****m/images/main/2/3203234450.jpg[/IMG]
My Releases
Injector 3G
Injector 2G
Injector 1G
Super Spammer
CA Cleaner
My Tutorials
How to Make a real Injector(PerX)
How to Make a Calculator(leeched)