Sabtu, 25 Juli 2015

RE: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

Glenn
I've seen that happen with enum's. It drives me crazy. It also happens with variables that might be spelled like reserved words or other variables with limited scope.

Sometimes you have to change the spelling to make the editor stop ass-u-me-ing what you want.

Sent from my Kindle Fire




From: "'Glenn Lloyd' argeedblu@gmail.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>
Sent: Sat Jul 25 17:29:36 PDT 2015
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

The editor autocorrect does strange things with used defined enums, however. Regardless of the case used in the declaration, autocorrect changes the case of the name in the declaration to whatever you type.

 

Glenn

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Saturday, July 25, 2015 6:50 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

 

Bob

 

I like that the editor has lots of "AutoCorrect" features. I do that lower case variable thing, too. It makes it so easy to catch typos.

Another thing that might eventually go away if VBA gets to be more like more mainstream syntax is the assumption of "True" as in:

If Me.Dirty Then Me.Dirty = False

 

Not only is that a single line code but the use of "Me.Dirty = True" can be written as I did above. The compiler gets that I mean True without typing it.

 

Regards,

Bill

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Saturday, July 25, 2015 3:47 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

 

It will compile Bill, but I don't like it J

 

I never use multiple statements with an Else. I used to be very 'correct' with no else and code it like

If suit = spades Then

 

    MsgBox "I win!"

End If

But I admit I prefer single lines and that is what I use now (does cause some small problems when trying to check back on multiple nested Ifs when there is one without an End If, but nesting usually helps here).

 

BTW, typing endif and getting End If is great in my view, I always do it and love that VBA corrects it (in the same way that I never type my variables in the define came-case, I type them lower-case and if they don't get corrected I know I have typed it incorrectly – we need all the help we can get), but I just wish it would work with endwith as well!

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: 24 July 2015 17:29
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

 

Bob - It's a non-nonsensical example made worse by being syntactically incorrect to start with.But my example is correct and will compile as it should.

 

While multiple statement lines are out of the ordinary, they are used from time to time. It's a matter of style. I tend to use them in If blocks if the Else line is short. Offhand, I can't think of any other place I'd use them.

 

Then there is the one-line If statement:

If suit = spades  Then MsgBox "I win!"

 

No End If needed.

Another funny thing about VBA, you can type endif and the editor will fix it for you.

 

-Bill



---In MS_Access_Professionals@yahoogroups.com, <bob.phillips@dsl.pipex.com> wrote :

Surely, it should be

 

 

   If 1 > 4 Then

      MsgBox "1 is greater than 4"

  Else

      MsgBox "1 is less than 4"

  End If

 

Or even

 

  MsgBox "1 is " & IIf(1 > 4, "greater", "less") & " than 4"

 

Multiple statement lines just don't feel right to me.

 

__._,_.___

Posted by: Bill Mosca <wrmosca@comcast.net>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (10)

.

__,_._,___

Tidak ada komentar:

Posting Komentar