Finding Corresponding EndIf

Question:
I’ve got ten pages of code and there’s an “If” on the first page, a bunch of “If…EndIf” statements throughout the code and the “EndIf” that corresponds with the first “If” lurks somewhere below. Short of just looking for the last “EndIf” (which would work in this case), I’d like to know how to find *any* block closing statement. That is, what’s the trick to finding a corresponding “EndIf”, “Wend”, etc. If the built-in module editor won’t cut it I’m open to suggestions for other editors.

Answer:
Unfortunately, there is no easy way to find the closing EndIf (or otherkeyword) statement. However, good code formatting is often a good solutionfor this problem. For each If/For/other keywords, indent all of the linesbelow it. As soon as you add the opening keyword, put in the closing oneand add a comment indicating which keyword the end one belongs to, as inthis example:

If i > 10 Then   … lots of code …End If  ‘ If i > 10 
This should help you find the ends of your loops. The other option, if itis possible, is to break the logical sections into subroutines, into whichyou pass the necessary variables.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

Top 5 B2B SaaS Marketing Agencies for 2023

In recent years, the software-as-a-service (SaaS) sector has experienced exponential growth as more and more companies choose cloud-based solutions. Any SaaS company hoping to stay ahead of the curve in this quickly changing industry needs to invest in effective marketing. So selecting the best marketing agency can mean the difference

technology leadership

Why the World Needs More Technology Leadership

As a fact, technology has touched every single aspect of our lives. And there are some technology giants in today’s world which have been frequently opined to have a strong influence on recent overall technological influence. Moreover, those tech giants have popular technology leaders leading the companies toward achieving greatness.

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.