PDA

View Full Version : Getting values from a textbox in a userform



Sunil TD
09-27-2012, 11:26 PM
Hi,

I have designed a form which has 1 textbox and 1 button.

In one of the VBA module the userform is getting popupped. I have to get the value from text box of the userform to a variable in the module only after the user clicks the button in the userform. Till then the module code should not be executed but the userform should be displayed.

Please help me how to get this problem solved.

Thank you for helping me in advance :bow:

Regards,
Sunil TD

mikerickson
09-28-2012, 07:04 AM
You could put this in the userform's code module
Private Sub CommandButton1_Click()
Me.Hide
End Suband call the userform with code like
Sub test()
Dim uiValue As String

UserForm1.Show
uiValue = UserForm1.TextBox1.Text
Unload UserForm1

If uiValue = vbNullString Then
MsgBox "user entered nothing"
Else
MsgBox "user entered " & uiValue
End If

End Sub