View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Retaining value of a string from a textbox on a form ??

Dan,

Try declaring it as a public variable in a standard codemodule, not the
userform codemodule.

HTH,
Bernie
MS Excel MVP
"Dan Thompson" wrote in message
...
I am working with a form which has a textbox that I am entering text into

and
than passing the the string value entered into the text box on my form to

a
string variable.
for example...

Sub test()
Dim MyTxtString as String
MyForm.Show
MyTxtString = MyForm.Mytextbox.value
MyForm.Hide
MsgBox (MyTxTString)
End Sub()

The problem is that the string from the textbox on MyForm does get

assigned
to MyTxtString variable, however as soon as the form his hidden the

variable
MyTxtString looses the value entered into the textbox and the value of
MyTxtString becomes "" (nothing).
How do I maintain the scope of MyTxtString to keep the value assigned to

it
even when the form is hidden ?

I have already tried declaring MyTxtString as a Public Global variable but
the scope and life of MyTxtString still is not maintained.
What am I doing wrong ?

Dan.