Results 1 to 14 of 14
  1. #1
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused

    [Tutorial]Saving/Loading a Listbox Contents

    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:
    Code:
    Inherits System.Windows.Forms.Form
    Dim w As IO.StreamWriter
        Dim r As IO.StreamReader
    3. Now to save a listbox contents use this code:
    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()
    4. Now to load a listbox contents.
    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()
    Its as simple as that.
    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.

  2. The Following 6 Users Say Thank You to Bombsaway707 For This Useful Post:

    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)

  3. #2
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Looks Good , Thank you


     


     


     



    The Most complete application MPGH will ever offer - 68%




  4. #3
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Quote Originally Posted by NextGen1 View Post
    Looks Good , Thank you
    Thanks and i can say confidently that this tut isnt leeched since i wrote it up myself xD

  5. The Following User Says Thank You to Bombsaway707 For This Useful Post:

    NextGen1 (02-23-2010)

  6. #4
    hopefordope's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Herndon,VA
    Posts
    264
    Reputation
    9
    Thanks
    86
    My Mood
    Psychedelic
    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)

  7. #5
    mnpeepno2's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    In a barren wasteland
    Posts
    905
    Reputation
    10
    Thanks
    81
    you cant use items.add but yes, you can
    looks good.


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

    My site: here
    My Blog: here
    My member's area: here
    Minecraft Sever Forum: here


    Minecraft Servers:

    Public:



    Private:



  8. #6
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Quote Originally Posted by hopefordope View Post
    Sorry if i bumped this but i hav a question
    can u do this same with a txt box
    Yes, although the saving/loading code wouldnt be the same.

  9. #7
    XGelite's Avatar
    Join Date
    Mar 2009
    Gender
    male
    Location
    Enter text here
    Posts
    1,344
    Reputation
    12
    Thanks
    276
    so would this work for .xml files as well?

  10. #8
    Zoom's Avatar
    Join Date
    May 2009
    Gender
    male
    Location
    Your going on my 24/7 DDoS hit list.
    Posts
    8,552
    Reputation
    127
    Thanks
    5,970
    My Mood
    Happy
    Great tutorial!
    -Rest in peace leechers-

    Your PM box is 100% full.

  11. #9
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Quote Originally Posted by XGelite View Post
    so would this work for .xml files as well?
    Although it would not be the same save/load code i suppose it could be implemented for .xml files
    Quote Originally Posted by hejsan1 View Post
    Great tutorial!
    Thank you

  12. #10
    hopefordope's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Herndon,VA
    Posts
    264
    Reputation
    9
    Thanks
    86
    My Mood
    Psychedelic
    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)

  13. #11
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    "C:\Documents and Settings\User\USERNAME
    \Desktop\"

    so.....

    Code:
    w = New IO.StreamWriter("C:\Documents and Settings\User\USERNAME
    \Desktop\sample.txt")
    You can use the code

    Code:
    Enviroment.Username
    to get the 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.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  14. The Following User Says Thank You to NextGen1 For This Useful Post:

    hopefordope (02-25-2010)

  15. #12
    Pixipixel_'s Avatar
    Join Date
    Oct 2009
    Gender
    male
    Location
    VCExpress.exe || France :D
    Posts
    2,087
    Reputation
    27
    Thanks
    742
    My Mood
    Cool
    Hehehe good job, great tut

  16. #13
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Quote Originally Posted by Pixipixel_ View Post
    Hehehe good job, great tut
    Thanks man

  17. #14
    hopefordope's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Herndon,VA
    Posts
    264
    Reputation
    9
    Thanks
    86
    My Mood
    Psychedelic
    Quote Originally Posted by NextGen1 View Post
    "C:\Documents and Settings\User\USERNAME
    \Desktop\"

    so.....

    Code:
    w = New IO.StreamWriter("C:\Documents and Settings\User\USERNAME
    \Desktop\sample.txt")
    You can use the code

    Code:
    Enviroment.Username
    to get the 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")
    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)

Similar Threads

  1. Simple Save/Load
    By kotentopf in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 8
    Last Post: 10-07-2010, 02:10 PM
  2. [Injector] Pornject ++ Internet Stream ++ Save\Load [v3]
    By XxDragonSharKxX in forum CrossFire Spammers, Injectors and Multi Tools
    Replies: 6
    Last Post: 07-02-2010, 10:16 AM
  3. [Help] VB.NET 2008 - Saving ListBox Items in Settings
    By Samueldo in forum Visual Basic Programming
    Replies: 12
    Last Post: 03-17-2010, 09:14 PM
  4. [Tutorial]Saving Checkbox True/False Statement
    By Blubb1337 in forum Visual Basic Programming
    Replies: 11
    Last Post: 02-05-2010, 08:36 PM
  5. [Tutorial] New Way to make CA load faster
    By Andyklk2009 in forum Combat Arms Hacks & Cheats
    Replies: 13
    Last Post: 10-08-2008, 04:24 PM