Results 1 to 3 of 3

vba: how to save the textbox value on an userform?

This is a discussion on vba: how to save the textbox value on an userform? within the Excel Questions forums, part of the Question Forums category; I have 2 userforms. On the main form, there is a button called "Setting". Click on it will bring up ...

  1. #1
    Board Regular
    Join Date
    Jun 2008
    Posts
    164

    Default vba: how to save the textbox value on an userform?

    I have 2 userforms. On the main form, there is a button called "Setting". Click on it will bring up the second form. On the second form, there is a textbox1 which has it's value defaulted to "abc". There is another button called "SaveAndQuit". Click on it will close the form #2 and return to form #1.

    If I don't change any thing, textbox1.value will always be "abc", but I want my program to remember the change I made to textbox1. That is, when an user typed "efg" to textbox1 and click "SaveAndQuit", textbox1.value should be changed to "efg". When that user click "Setting" again, he will see textbox1 is "efg" instead of "abc".

    The textbox1.value will be set back to default "abc" after all operation finished. That means, the value change made to textbox1 is not permanent to the program.

    Private sub userform_initialize()
    textbox1.value="abc"
    end sub

    Private sub textbox1()
    end sub

    private sub SaveAndQuit()
    unload form2
    end sub


    Thanks!

  2. #2
    Board Regular iliace's Avatar
    Join Date
    Jan 2008
    Location
    Maryland, USA
    Posts
    2,853

    Default Re: vba: how to save the textbox value on an userform?

    In the SaveAndQuit thing, hide the form instead of unloading it. Then, you can still refer to its members from the other form.

    For example, you could create a public variable (or better yet, private variable + public property) to store the value, then Form 1 will fetch that value and unload Form 2.
    Use [ CODE ] tags. Reply to the original thread. Post an example.

  3. #3
    Board Regular
    Join Date
    Jun 2008
    Posts
    164

    Default Re: vba: how to save the textbox value on an userform?

    Thanks! Hide is exactly what I need.

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com