?
Solved

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

Posted on 2007-04-05
6
Medium Priority
?
190 Views
Last Modified: 2010-04-30
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?
0
Comment
Question by:bergertime
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18860044
Not without storing the new value in some kind of external file or the registry.

You have a preference?...
0
 
LVL 2

Author Comment

by:bergertime
ID: 18860114
External file sould work.  Is either way better?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18860252
Did you want to save just ONE TextBox or all TextBoxes?  ...any other data you need to save?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:bergertime
ID: 18860327
No, just that one textbox.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 18860765
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
            sr.Close()
        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)
        sw.WriteLine(TextBox1.Text)
        sw.Close()
    End Sub

End Class
0
 
LVL 2

Author Comment

by:bergertime
ID: 18861048
Thanks!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question