Solved

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

Posted on 2007-04-05
6
175 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now