Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Anpu Massri   on Mar 18 In MS Office Category.

  
Question Answered By: Burkett Bernard   on Mar 18

Do you mean the WHOLE SHEET'n macros? It shows as 302K!

> > You can't define a public Dim. ...
> > use Public at the top of the module.
Was trying to be succinct: That's what I meant by [Public "Dim"].
The "Dim" is implied in a Public Declaration at the Module Level.
It's like the segment below...

I was thinking there may be some subtile thing with variable  scope
between Forms, Modules and Sheet code  (code in the Sheet1, Sheet2
areas)...

> ... typo's in your variable names.

I usually type in lower case and when it snaps to upper, figure I
got it right. EXAMPLE NAME = ModeNFilt() However, this wouldn't
show up a "double Declare" if they're both spelled the same.


> Using "Option Explicit" *** YEP! Already.

> ...declare the variable as Public in only one place or
> ... different variables with ... different scope.

Allowing "double Declares" seems to fly in the face of the def.
of "Public". From all the stuff on scope  & lifetime @ MSDN, this
_is_ how I do understand it. Having one Public declaration at one
Module level should make it 100% Global for the whole Project...DONE!
Being allowed to have two Public declarations in two different
Module levels (in the Declarations section) would mess things up, and
one would think I should cause an Ambiguity error....
Perhaps I still have it declared twice and don't know it... When
debugging, I *DID intentionally double declare and got some versions
to run W/O an Ambiguity or compile error (some also DID error)

I better carefully do a Find across the Project...


> The example below seems to allow the user form to change the array
> every time sub One() is called without loosing the data.
> Brad

Only diff I see is that I do the Hide *IN* the Form code, and
after hiding, see the nulled array  in "Sub Two" like this. :

> Module1:
> Public MyArray(1 To 10) As String ' YEP!

> Sub One() ' Fires as the result of a Button1_Click
> UserForm1.Show
> End Sub

> Sub Two() ' Fires as the result of a different Button2_Click
Debug.Print "|"; MyArray(1); "|" ' Prints the Nulls >> ||
' I do the thing with the "|" to show when
' a number has the extra "sign" space, or
' contains a space / non-printing char.
> End Sub

> UserForm1 Module:
> Private Sub CommandButton1_Click()
> ' Don't know why you did this>> temp = MyArray(1)
> MyArray(1) = TextBox1.Value ' *** Yep!
Debug.Print MyArray(1) ' Prints the box.value A-OK
> UserForm1.Hide
> End Sub
*** Now click to Call Two...

Before I send the sheet (it's big) I better scrub the declarations
throughput the Project.

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Variable scope & Lifetime limits causing trouble Or get search suggestion and latest updates.


Tagged: