LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Disappearing Public Variable

I declare a Variable as Public (to preserve its value throughout code
execution) eg:-
Public MyText As Variant (this is done in a Standard Module)
Then in a UserForm I have:-

"Private Sub CommandButton1_Click()
MyText = TextBox1
(The Locals Window correctly shows MyText has whatever I put in TextBox1)
Do some other things
Unload UserForm3
End Sub"

When the UserForm is unloaded and execution returns to a Standard module I
need to use the value in MyText - but in the Locals Window I see that
MyText=0.

I expected the value in MyText to be retained even though the UserForm where
it was created has been unloaded.

What am I doing wrong?

--
donwb
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Public Variable on Open jlclyde Excel Discussion (Misc queries) 4 September 11th 09 07:03 PM
Public variable Jack New Users to Excel 4 March 18th 06 09:35 PM
How to declare variable as public. Mark Excel Programming 3 April 7th 05 06:27 PM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"