In the VB IDE, 'if' statements should be bracketed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In the Visual Basic IDE, if statements should have brackets to show which if
goes with which end if:
+If Me = P!ssed then
| +If Sky = Blue then
| +End if
+End if

It would make checking code a lot easier. I'm currently missing an end if
(apparently) and after combing through the code by hand, and then again by
reducing it using excel, I still haven't found the errant 'if' statement.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...f5f516&dg=microsoft.public.access.formscoding
 
aoeusnth,

It would make it easier for someone to help you if you'd post the actual
code in question.

Brian


aoeusnth said:
In the Visual Basic IDE, if statements should have brackets to show which if
goes with which end if:
+If Me = P!ssed then
| +If Sky = Blue then
| +End if
+End if

It would make checking code a lot easier. I'm currently missing an end if
(apparently) and after combing through the code by hand, and then again by
reducing it using excel, I still haven't found the errant 'if' statement.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/com...f5f516&dg=microsoft.public.access.formscoding
 
aoeusnth said:
In the Visual Basic IDE, if statements should have brackets to show which if
goes with which end if:
+If Me = P!ssed then
| +If Sky = Blue then
| +End if
+End if

It would make checking code a lot easier. I'm currently missing an end if
(apparently) and after combing through the code by hand, and then again by
reducing it using excel, I still haven't found the errant 'if' statement.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/office/com...f5f516&dg=microsoft.public.access.formscoding


Check out Stephen Bullen's site. It is an Excel site but it has an excellent
VBA code indenter - "IndenterVBA". (I am using A2K)


http://www.oaltd.co.uk/Excel/SBXLPage.asp

If you install the indenter and reformat the code (indent - ctl-P for the
current procedure/ ctl-M for the module), you will quickly see where you are
missing the "End If".

In the IDE you can change many options to configure number of spaces to indent,
indent comments, etc.


HTH
 
I always indent my code by exactly 3 spaces "inside" each construct
such as if/else/endif.

For example:

if blah then
this
else
that
endif

Then, if you get to an else, or an endif, but you are not back in the
column where you started from, you know immediately that you have
missed something out.

Of course, the number of spaces that you choose to indent, is a
personal preference. You might want 4, or 8, or whatever. The main
thing is, to be consistent in every line of code that you write.

HTH,
TC [MVP Access]
 
aoeusnth said:
In the Visual Basic IDE, if statements should have brackets to show which if
goes with which end if:
+If Me = P!ssed then
| +If Sky = Blue then
| +End if
+End if

It would make checking code a lot easier. I'm currently missing an end if
(apparently) and after combing through the code by hand, and then again by
reducing it using excel, I still haven't found the errant 'if' statement.

You should also look for unclosed do/loop, with/end with, for/next,
while/wend, etc. constucts in the same block of code. Sometimes the
wrong construct is identified as the problem if they are nested.
 
For reference, Visual Studio.Net has automatic indenting built in as well as
automated entry of the 'other part' of things like Ifs (i.e. you type if
whatever then, hit enter and it automatically drops in the end if). Given
that MS have that functionality done, it'd be nice to think that they'll
build it in to the next version of Access.

You could also just label your end ifs e.g.

if whatever=whichever then

end if 'whatever=whichever


aoeusnth said:
In the Visual Basic IDE, if statements should have brackets to show which if
goes with which end if:
+If Me = P!ssed then
| +If Sky = Blue then
| +End if
+End if

It would make checking code a lot easier. I'm currently missing an end if
(apparently) and after combing through the code by hand, and then again by
reducing it using excel, I still haven't found the errant 'if' statement.

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/office/com...f5f516&dg=microsoft.public.access.formscoding
 
Unfortunately, there's no way that this feature can be added to the next
version of Access, because the VBA IDE is not part of Access. What would be
required is a new version of the VBA IDE, and Microsoft have made if very
clear that they have no plans to release any new version of the VBA IDE.
 
So is the idea that they package VS Office 2005 into the next version of
Office?
 
I'm sorry, Rob, but I probably shouldn't go into any more detail here - it
gets to be too difficult trying to remember what's been publicly announced
and what's still under NDA. Best I can do right now is to advise you to keep
an eye on Erik Rucker's blog at http://blogs.msdn.com/access/. I'm afraid
there doesn't seem to be much on programmability there yet, but perhaps that
will change. Or perhaps you may find something of interest among the other
Office blogs ... http://blogs.msdn.com/search.aspx?q=office&p=1
 
....ah... the old "I could tell you, but I'd have to kill you afterwards"
response. Guess us mere mortals will just have to wait to find out, but
I'll keep on eye on those blogs in the meantime.

Thanks.
 
Back
Top