kieran989
05-04-2017, 05:35 PM
Im trying to pass a string from a userform textbox to a public variable defined in a module. Cant for the life of me figure out whats happening. My code looks like this:
Module code
Option Explicit
Public test As String
Sub btn_showuserform()
userform1.Show
MsgBox test
End Sub
Userform code
Option Explicit
Sub btnOk_Click()
test = userformtextbox.Value
Unload Me
End Sub
For some strange reason it works if I show the message box. But If i dont show the messagebox the value isnt passing to the variable??
Also if i dont show the messge box but run the code from within in the userform code, the value does pass??
Module code
Option Explicit
Public test As String
Sub btn_showuserform()
userform1.Show
MsgBox test
End Sub
Userform code
Option Explicit
Sub btnOk_Click()
test = userformtextbox.Value
Unload Me
End Sub
For some strange reason it works if I show the message box. But If i dont show the messagebox the value isnt passing to the variable??
Also if i dont show the messge box but run the code from within in the userform code, the value does pass??