Results 1 to 10 of 10

Thread: Clear all variables? Please??

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Location
    Houston, TX
    Posts
    7

    Re: Clear all variables? Please??

    you can declare module specific variables by declaring them as Private, therefore they will not be available outside of the module..
    it's my understanding that this is true when you make a private declaration at the module level only, which is actually the same as using a dim statement at the module level. if you use a public declaration at the module level, then the variable is available outside the project as well as throughout the module. as far as i know you can't use public or private declarations at the procedure level.

    to clarify, i want to declare variables such that they will be shared across multiple procedures within a single module, and i want some way to clear their values at the beginning and/or end of code execution.

    i've never used class modules, and i'm not familiar with how they work and how they compare to standard modules... guess i'll have to check them out.

    -agl

  2. #2
    Lively Member JustinLabenne's Avatar
    Join Date
    Jul 2005
    Location
    Ohio
    Posts
    64

    Re: Clear all variables? Please??

    If they are declared at Module level:

    Reset the values of them at the end of each procedure,

    VB Code:
    1. Option Explicit
    2.  
    3. Dim mlLongVar As Long
    4.  
    5. Sub ProcOne()
    6. mlLongVar = 10
    7. MsgBox mlLongVar
    8. mlLongVar = Empty 'Reset to nothing
    9. End Sub
    10.  
    11.  
    12. Sub ProcTwo()
    13. MsgBox mlLongVar
    14. End Sub
    Attached Files Attached Files
    Justin Labenne
    www.jlxl.net

Posting Permissions

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



Click Here to Expand Forum to Full Width