VB.NET: n00b question

Discussion in 'Web Design & Coding' started by Lukas, Oct 17, 2003.

  1. Lukas

    Lukas Real Name No Gimmicks

    Hi, I jyst started with VB.NET.

    I'm writing a small app. It's my first time so be gentle :p ...

    I made a 'configuration'-form, where the user can store some information the program needs. Basically, there are only three textboxes that should store data (hostnames to be exact). Now my question is how do I make my application remember what the user typed into the textboxes?

    I can type values into the textboxes, and the app works fine, but it dissapears when I restart my application. I really don't know how to store that 'configuration' so that it will be there when the appliocation starts for a second time.

    I don't really want to use an connection to a access database or SQL database, but I need my configuration to be saved INTO my application, textfile, ini-file or xml... and retrieved from that file after the app is restarted.

    Can any1 help?


  2. X-Istence

    X-Istence * Political User

    Save it to a text file, like you said :D.

    Search google as there are many examples available.
  3. Lukas

    Lukas Real Name No Gimmicks


    Now I can write the textfile with this code:

    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click 
        Dim sw 
    As StreamWriter = New StreamWriter("config.txt"
    sw.WriteLine("HOST1=" Host1.Text
    sw.WriteLine("HOST2=" Host2.Text
    sw.WriteLine("HOST3=" Host3.Text
    End Sub 
    but I don't know how to read specific lines out of it. I need the Host1, Host2 and Host3 textboxes to retrieve the previously typed info from the text file, even when the app is restarted. So the textboxes need to be "bound" to the HOSTx= lines in the textfile.


    Host1.Text = config.txt, Line 1
    Host2.Text = config.txt, Line 2 and so on...

    I looked for it on Google, but I don't exactly know how to build the search query... (means: I don't know what to look for)