Results 1 to 13 of 13

VBIDE Challenge #6 - Relocating Dim lines in procedures

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

    VBIDE Challenge #6 - Relocating Dim lines in procedures

    VBIDE - Visual Basic for Applications Extensibility 5.3

    I am intrigued by the idea of writing code that will report on or edit existing code. Unfortunately I am yet to master the use of VBIDE - my skill level on this is currently little-to-none.

    So every so often, I post a new VBIDE challenge hoping that some forum user will solve it for me (either from kindness and/or for the love of the challenge).


    Here's challenge #6.

    Can we use VBIDE to convert a project from one coding style to another?

    In this challenge we are looking at Dims. Some coders prefer to declare these just before they are used, others prefer to place them at the top of the procedure.

    [UPDATE - This challenge beaten by romperstomper] Loop through every procedure in ThisWorkbook (with the exception of the VBIDE module) and move any Dim found to the top ( .ProcBodyLine ?) of that procedure. Unskilled though I am, I think this is doable. I'm guessing it would be a good idea to loop from the bottom of each module upwards.

    [UPDATE - This challenge beaten by romperstomper] The only drawback I can see would be the Dims would be placed before any comment lines at the top of the procedure. So extra points if you can detect comment lines at the top of a procedure and move the procedural Dims below these.


    [UPDATE - This challenge not beaten yet] P.S. For anyone looking for an even more advanced challenge - try converting to the Just In Time coding method. Any Dims in a procedure are moved to the line before the first instance they are used in that procedure.
    Last edited by mc84excel; 11-21-2014 at 04:43 PM. Reason: Update to indicate beaten challenges
    *******************************************************

    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)

Similar Threads

  1. [SOLVED] VBIDE Challenge #5 - Listing Procedures in VB Project
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2014, 10:43 PM
  2. Relocating data
    By Frenchie4016 in forum Excel General
    Replies: 5
    Last Post: 06-22-2010, 09:52 AM
  3. Dim VBComp As VBIDE.VBComponent
    By Jim Jackson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2006, 04:15 PM
  4. VBIDE.VBComponent
    By michaelberrier in forum Excel General
    Replies: 3
    Last Post: 06-12-2006, 12:55 PM
  5. Relocating a macro
    By davegb in forum Excel General
    Replies: 4
    Last Post: 02-08-2005, 11:06 AM

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