Results 1 to 13 of 13

Seeking knowledge on an unknown VBA concept

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Lightbulb Seeking knowledge on an unknown VBA concept

    Disclaimer: "unknown" in Thread title means that I don't know the name of the concept I am about to describe. (Have not done a VBA course yet so please forgive what is probably a newbie question).


    Please see pseudo code below
    Sub Test1()
    dim a as string
    dim b as long
    a = "xyz"
    b = 1.45
    (some code here)
    End Sub
    
    Sub Test2()
    (some code here)
    dim a as string
    a = "xyz"
    (some code that uses a)
    dim b as long
    b = 1.45
    (some code that uses b)
    End Sub
    Assume that the above two sketches are the same macro except that in the first I am declaring my Dims etc as soon as the macro starts and in the second I am declaring 'just in time' (so they are declared just before the code lines that require them).
    1. What is the name of the concept I have described above?
    2. What is the pros & cons of each method?
    3. Would the second method be faster as the memory doesn't have to hold the data when it doesn't need to?

    Appreciate any answers to the above!
    Last edited by mc84excel; 02-17-2013 at 10:47 PM.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1