Results 1 to 6 of 6

Thread: Save Contents in TextBox

  1. #1

    Thread Starter
    Banned
    Join Date
    Aug 2009
    Posts
    333

    Save Contents in TextBox

    How would I save the contents in the textbox so that next time the form containing the textbox is opened, it will still have the same text?

  2. #2
    Addicted Member
    Join Date
    Jun 2009
    Posts
    245

    Re: Save Contents in TextBox

    Just add a settings file to your project and save it there

    Project > add new item > general > settings file

    Take a look at this thread on how to use the file: http://www.vbforums.com/showthread.php?t=579165

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Save Contents in TextBox


  4. #4

    Thread Starter
    Banned
    Join Date
    Aug 2009
    Posts
    333

    Re: Save Contents in TextBox

    How would I use it to save text
    Im using something like this and it doesnt work Nothing shows up in the textbox
    Code:
    Public Class Dialog1
    
        Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            TextBox1.Text = My.Settings.TextBoxUser
            My.Settings.Save()
            Me.Close()
        End Sub
    Code:
        Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
            TextBox2.Text = My.Settings.TextBoxUser
        End Sub
    End Class
    Last edited by Iamazn; Sep 5th, 2009 at 12:56 PM.

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,423

    Re: Save Contents in TextBox

    try Application Settings.

    in your design time view, select the textbox.
    expand [ApplicationSettings] in the properties window.
    select 'text' + click the dropdown arrow to the right.
    click 'New', type in a name for the property + click OK.

    thats all you need to do + your text will be saved when you close your application + reloaded when you run it next time.

  6. #6
    Addicted Member
    Join Date
    Jun 2009
    Posts
    245

    Re: Save Contents in TextBox

    Quote Originally Posted by Iamazn View Post
    How would I use it to save text
    Im using something like this and it doesnt work Nothing shows up in the textbox
    Code:
    Public Class Dialog1
    
        Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
            Me.DialogResult = System.Windows.Forms.DialogResult.OK
            TextBox1.Text = My.Settings.TextBoxUser
            My.Settings.Save()
            Me.Close()
        End Sub
    Change "TextBox1.Text = My.Settings.TextBoxUser" to "My.Settings.TextBoxUser = TextBox1.Text"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width