Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2007-04-05
6
183 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

839 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