Procedure Size

Posted on 2006-05-18
Last Modified: 2010-05-01
Is there a limit on how big a procedure can be? I keep getting an error that my procedure is too big...

Question by:KalluMama
    LVL 12

    Accepted Solution

    Yes there is a limit on how big a procedure can be.  Comments in a procedure also count.

    If you have too many lines of comments in your procedure, try shortening or cutting down some of them to be as short and meanful as possible.

    Or try splitting your procedure into smaller, multiple subroutines.

    Author Comment

    cool thanks...i never knew that...i will keep that in mind!!
    LVL 12

    Expert Comment

    The following is an excerpt from MSDN.

    The maximum size of the internal code for an individual procedure in Visual Basic is 64K bytes. Microsoft Visual Basic for Windows uses Microsoft Visual Basic for Applications, which generates more generic internal code. This generic code allows for compatibility with a wider range of processors. This makes the internal code larger, so it can cause very large procedures to exceed the 64K limit and fail to compile.

    Split the large procedure into two or more smaller procedures.

    This behavior is by design.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now