473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Anyone know of an A97 utility to help solve If - EndIf mixups?

MLH
Would love to be able to click on any If-statement
and launch a utility that would find what A97 believes
to be its corresponding EndIf. Such a tool would save
me lots of time as I am forever botching them up and
having to go back 'n fix 'em.
Mar 24 '06 #1
7 1591
Perhaps someone else can suggest a tool, but hope this experience helps.

When I first started coding, I used to print out the code and draw lines to
match the block operations such as If...EndIf, or For...Next. Haven't done
that for years now. FWIW, here's my current approach.

1. Indent
You probably do this. Indenting every block operation is the simplest way to
help keep them matched.

2. Modularize
Break the code down into smaller procedures. Ideally, a procedure should be
no more than a couple of screenfuls. Helps avoid huge numbers of embedded
indents.

3. Outside in
Type the End If immediately after the If. Your code is therefore coming up
from the bottom as well as down from the top. If you are not doing this, it
will probably solve the issue for you.

For example, you type:
If x < 0 Then {Enter} End If {Up} {End} {Enter} {Tab}
and you are then ready to code the inner part of the If block.

4. Rotate your monitor
Why code on a landscape monitor, when it would be so much easier to stay on
top of the blocks with portrait orientation?

A couple of years ago I did move to dual monitor: application on the left
(normal landscape) and code on the right. It was then obvious that the right
monitor needed to be portrait, so I flipped the old 19" CRT on its side and
told the nVidia driver to rotate the image.

This suggestion won't suit everyone, but the flippin' code monitor is the
best hardware change I have made in the last few years. And the combination
of these 4 approaches means I never get lost any longer with block
operations.

HTH.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthState.net> wrote in message
news:n7********************************@4ax.com...
Would love to be able to click on any If-statement
and launch a utility that would find what A97 believes
to be its corresponding EndIf. Such a tool would save
me lots of time as I am forever botching them up and
having to go back 'n fix 'em.

Mar 24 '06 #2
MLH
Thanks, Allen. They were all very helpful comments.
I am doing #1. I couldn't live without indenting.
I got the red pen out and have been drawing lines for hours.
Plead guilty to not being as modular as I could be.
I like #3. A few more instances like today and perhaps I'll remember
always to do it.
Would love to hear everyone's comments on experience w/ dual monitors
and particularly what brands/models have been found best. I'm only
familiar with architect/engineering firms using them in CAD apps. That
has been a long time ago though.

BTW - when I got to the bottom of my problem, it was that I'd
overlooked inserting 2 End With lines. Because the error msg
was blaming my If - EndIf coding, I spent all my time chasing that
down like a dumb!f&xxxWXX!!!
Mar 24 '06 #3
MLH wrote:
Would love to be able to click on any If-statement
and launch a utility that would find what A97 believes
to be its corresponding EndIf. Such a tool would save
me lots of time as I am forever botching them up and
having to go back 'n fix 'em.


I used to work with a code editor in a program similar to SourceSafe
(where you checkout/in the code) and it had lines that drew the
loop/endif lines. I think it would be a PITA to contantly be using two
editors to do your coding. You might want to check
http://www.tucows.com and see if they have any code editors that does
what you want.

Allen's suggestions were excellent. Here's another suggestion...it may
be a hard habit to correct your current coding style but in your case
it'd be best to change it. Every time you enter an IF/Do While/Select
Case immediately enter EndIf/Loop/EndSelect on the next line. Then
insert a blank line, tab, then start coding. You shouldn't worry about
your current style then.

Mar 24 '06 #4
MLH <CR**@NorthState.net> wrote in
news:s4********************************@4ax.com:
Thanks, Allen. They were all very helpful comments.
I am doing #1. I couldn't live without indenting.
I got the red pen out and have been drawing lines for hours.
Plead guilty to not being as modular as I could be.
I like #3. A few more instances like today and perhaps I'll remember
always to do it.
Would love to hear everyone's comments on experience w/ dual monitors
and particularly what brands/models have been found best. I'm only
familiar with architect/engineering firms using them in CAD apps. That
has been a long time ago though.

BTW - when I got to the bottom of my problem, it was that I'd
overlooked inserting 2 End With lines. Because the error msg
was blaming my If - EndIf coding, I spent all my time chasing that
down like a dumb!f&xxxWXX!!!


Also, I sometimes do this:

if some-complex-boolean-expression then
....big nasty tree
end if 'some-complex-...

I put enough in the comment after the END IF of the expression to be
evaluated so I can see what it's referring to.

Or, paste the code into an editor that lets you do code folding once it
knows it's working on VB/VBA code...

Mar 30 '06 #5
I use the WriteSimpleShortCode Utility found at
http://www.abovetheshoulders.com.

Mar 30 '06 #6
Allen Browne wrote:
3. Outside in
Type the End If immediately after the If. Your code is therefore coming up
from the bottom as well as down from the top. If you are not doing this, it
will probably solve the issue for you.

For example, you type:
If x < 0 Then {Enter} End If {Up} {End} {Enter} {Tab}
and you are then ready to code the inner part of the If block.


I sometimes find it useful to take this a step further by sticking an
Else in there also. It forces me to make sure the Else part, if any,
gets accounted for.

James A. Fortune
CD********@FortuneJames.com

Mar 30 '06 #7
MLH
I know, I know. It is a better way. No doubt.
Find myself kicking my own arse time 'n time again
for not following the advice.
I use the WriteSimpleShortCode Utility found at
http://www.abovetheshoulders.com.


Apr 1 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hafeez | last post by:
I am having real trouble compiling this code http://www.cs.wisc.edu/~vganti/birchcode/codeHier/AttrProj.tgz The attachment shows errors when compiled using the current version of g++ in a...
1
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h...
2
by: Mike Metzger | last post by:
I've been running an Access2000 database for a couple years on a Win2k machine fine. We tried to copy the database over to another machine that already had Access2000 installed. When we tried to...
5
by: John Baker | last post by:
Hi: I have PSD995 installed, and find it a good program. I have been told that using Access you can set up the PDF file name and location using scripting with this application so that PDF files...
7
by: hierro | last post by:
I have a list of functions (all with suffix T). For each one, I need to implement the following: FunctionT() { if (some_condition) { // do some conversion first FunctionW(); // then do some...
11
by: Chris Croughton | last post by:
I have a requirement to partially preprocess C code. By 'partially' I mean that I need to define some macros (to the utility) and have it preprocess only those macros, leaving everything else...
1
by: Dhanak | last post by:
I have around 1000 aspx files that contains standard lines intended for debugging purpose.Now before we put these to production we need to remove these lines from all files. Instead of doing it...
8
by: Zach | last post by:
I am looking for a good ADO.NET book to read. I know nothing about ADO as yet. If anyone has read the book - would it be ok for starters? What did you think of the book? If you didn't like the...
0
jeffbroodwar
by: jeffbroodwar | last post by:
Hi, I'm tying to develop a program that uses a radio button wherein if this radio button is clicked, it'll do a loop at screen block to display the select option controls that i have. i used : ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.