How do I copy the default Userfom textbox value opened?

Asked

Viewed 1,643 times

0

There’s an easier way than writing x = UserForm1.textbox2.value ?

That instruction means: Copy the value of the Userform1 textbox.

I wanted to replace the "Userform1" statement with something that means "Open Userform".

i.e.: copy the value of the text box 1 of the "Open Userform".

  • If it is in vb6 try to expose a Property Get to consume the value of your control this would be a more elegant way. Another point create instances of forms this will reduce the number of failures in your application, because accessing the form directly will not be downloaded.

  • If you omit Userform the VBA will already use the Active Form, so with textbox2.value it already performs in the userform texbox2. Already if you want in the active textbox you can use the Class modules

2 answers

0

To get anything from a form that is currently open, just use the "me":

a = me.textBox.value

-1

    For i = 0 To Forms.Count - 1
    If Forms(i).ZOrder = 0 Then
        Forms(i).TextBox1.text
    End If
    Next

Will it help you?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.