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: Angel Watkins   on Mar 18

First, make sure you don't have any typo's in your variable
names.
Using "Option Explicit" and declaring every variable, the
compiler
will give you an error if you accidentally make such a typo. Then,
make sure you declare the variable  as Public in only one place or
you can end up with the different variables with the same name, but
different scope.

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

Module1:
Public MyArray(1 To 10) As String
Sub One()
UserForm1.Show
End Sub
Sub Two()
UserForm1.Hide
End Sub

UserForm1 Module:
Private Sub CommandButton1_Click()
temp = MyArray(1)
MyArray(1) = TextBox1.Value
Call Two
End Sub

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: