Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Saving my Application
 

Saving my Application

Hi all

I have an application which consits of a combobox a textbox. There is also a button which I can add a name into the combobox and a telephone number into the textbox and abutton to delete. The application works fine but when I close the form and re-open the application it does not save any names or numbers that I entered before.

Public Class Form1
    Dim number(10) As String
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox1.Text = number(ComboBox1.Items.IndexOf(ComboBox1.Text))
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click      
        ComboBox1.Items.Add(ComboBox1.Text)
        number(ComboBox1.Items.IndexOf(ComboBox1.Text)) = TextBox1.Text
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load      
        ComboBox1.Items.Add("") : number(0) = ""
    End Sub

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        On Error Resume Next
        Dim temp As Integer = (ComboBox1.Items.IndexOf(ComboBox1.Text))
        ComboBox1.Items.Remove(ComboBox1.Text)
        For i = temp To 10
            Debug.Print(number(i))
            number(i) = number(i + 1)
        Next i
        TextBox1.Text = ""

    End Sub



End Class
rez1970  Friday, June 12, 2009 8:39 PM
Hi rez1970,

Based on my understanding,the problem you are facing is how to save the data you entered in the form.

The above code doesn't provide anything that persists the data, in .NET, you can try to use UserSettings to store your data so that you can reload data when the application starts a new sesison.

You can refer to this article for steps on how to use Settings. The code in that article is C#, if you have problem with this, please feel free to let me know.



Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Monday, June 15, 2009 11:40 AM
Hi rez1970,

Based on my understanding,the problem you are facing is how to save the data you entered in the form.

The above code doesn't provide anything that persists the data, in .NET, you can try to use UserSettings to store your data so that you can reload data when the application starts a new sesison.

You can refer to this article for steps on how to use Settings. The code in that article is C#, if you have problem with this, please feel free to let me know.



Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Monday, June 15, 2009 11:40 AM

You can use google to search for other answers

Custom Search

More Threads

• Newbie I'm sure it's an obvious answer
• display sequential images on a window form
• Finally some official info & page update
• ObjectDisposedException
• Need Help
• PocketVision vs Offline App Block
• how come <i>Microsoft.ApplicationBlocks.Data</i> does not included in the C# project?
• Nox invasion
• TaskVision WebService Source
• Middle Pane Generalization