Solved

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

Posted on 2007-04-05
6
180 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 85

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 85

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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 2

Author Comment

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

Accepted Solution

by:
Mike Tomlinson earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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