declaring variables - help!!!
declaring variables - help!!!
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: declaring variables - help!!!

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    42
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Dear all,

    I am having difficulty with the whole idea of setting variables.
    I want to declare a variable in one user form that then gets used in a different user form.
    I have tried making sure all subs are not private, I have tried declaring the variable in the option explicit section. I have tried declaring it at the start of a sub etc. I have been told to try dim myvariable as public, that doesn't work, I have tried public myvariable and public dim myvariable, I've tried the help files - I'm going loopy!
    Each time I run the routines the variable shows up in the locals window but then later in a different form the variable when called is empty.

    Can anybody explain how I keep a variable in memeory to use anywhere within a workbook/form

    Many thanks

    Andy

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The approach I use with multiple forms, which works for me, but probably isn't the 'best' way, is to put all my variable handling procedures into a standard module and have events from within the form module call procedures from the standard module. In this way you can have all your variables declared in one or more standard modules which gets round the probelm of variables losing scope. Note that if you adopt this approach, from within the standard module you need to refer to controls on your userforms explicitly ie

    Form1.TextBox1.Text rather than just TextBox1.Text


  3. #3
    New Member
    Join Date
    Feb 2002
    Posts
    42
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Dear Mudface

    thanks for both your replies, will get to work on them shortly, although I'm still not sure about the variables issue....lol

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com