Change the default text property in a textbox in VB.NET 2003

In VB.Net 2003.  I make a textbox and set the text property to 'whatever'.  Can I change this value from my program so the next time I start the program it has the new value in the textbox?
Who is Participating?
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Here is the simplest case scenario using VB.Net 2005.

(VB.Net 2003 has a different FormClosed() event but I can't remember it's exact name at the moment...)

Public Class FormC

    Private fileName As String = "TextBox1.txt"

    Private Sub FormC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If System.IO.File.Exists(fileName) Then
            Dim sr As New System.IO.StreamReader(fileName)
            TextBox1.Text = sr.ReadLine
        End If
    End Sub

    Private Sub FormC_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Dim sw As New System.IO.StreamWriter(fileName)
    End Sub

End Class
Mike TomlinsonMiddle School Assistant TeacherCommented:
Not without storing the new value in some kind of external file or the registry.

You have a preference?...
bergertimeAuthor Commented:
External file sould work.  Is either way better?
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Did you want to save just ONE TextBox or all TextBoxes?  ...any other data you need to save?
bergertimeAuthor Commented:
No, just that one textbox.
bergertimeAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.