Home All Groups Group Topic Archive Search About
Author
20 May 2010 11:03 PM
Tony Toews [MVP]
Folks

I came across the following line of code which errors out.

If lrc <> ERROR_NONE Then Error 5

You can see examples of this code in MS KB articles.   For example
http://support.microsoft.com/kb/210860

This compiles but at execution time causes an error.  Now this isn't a
big deal as the code is going to drop out of the routine anyhow. 

But I'm curious.  What is the Error 5 supposed to be doing?

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/

Author
20 May 2010 11:18 PM
Nobody
Show quote Hide quote
"Tony Toews [MVP]" <tto***@telusplanet.net> wrote in message
news:rnfbv59609li420afseegar284ive2i15l@4ax.com...
> Folks
>
> I came across the following line of code which errors out.
>
> If lrc <> ERROR_NONE Then Error 5
>
> You can see examples of this code in MS KB articles.   For example
> http://support.microsoft.com/kb/210860
>
> This compiles but at execution time causes an error.  Now this isn't a
> big deal as the code is going to drop out of the routine anyhow.
>
> But I'm curious.  What is the Error 5 supposed to be doing?

It simulates an error, as if it happened. See "Error statement" in MSDN, and
also Err.Raise, which does the same thing. Confused yet? Try this fun code:

Option Explicit

Private Sub Form_Load()
    Dim i As Long

    On Error Resume Next
    For i = 1 To 20
        Err.Raise i
        Debug.Print "Error " & Err.Number & ": " & Err.Description
        Err.Clear
    Next

End Sub
Author
21 May 2010 12:04 AM
Karl E. Peterson
Tony Toews [MVP] wrote:
> Folks
>
> I came across the following line of code which errors out.
>
> If lrc <> ERROR_NONE Then Error 5
>
> You can see examples of this code in MS KB articles.   For example
> http://support.microsoft.com/kb/210860
>
> This compiles but at execution time causes an error.  Now this isn't a
> big deal as the code is going to drop out of the routine anyhow. 
>
> But I'm curious.  What is the Error 5 supposed to be doing?

Signals the calling routine it passed an invalid argument.  :-)

--
..NET: It's About Trust!  http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org
Author
21 May 2010 12:49 AM
Larry Serflaten
"Tony Toews [MVP]" <tto***@telusplanet.net> wrote

> I came across the following line of code which errors out.
>
> If lrc <> ERROR_NONE Then Error 5
<...>
> But I'm curious.  What is the Error 5 supposed to be doing?


Its supposed to cause an error.


LFS
Author
21 May 2010 12:05 AM
Karl E. Peterson
Larry Serflaten wrote:
> LFS

Your clock is hosed.  Shouldn't you be -0500?

--
..NET: It's About Trust!  http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org
Author
21 May 2010 1:32 AM
Larry Serflaten
"Karl E. Peterson" <k***@exmvps.org> wrote
> Your clock is hosed.  Shouldn't you be -0500?

Its just after 7:30 (CST is -6:00) as I post this.  I'll see what the
servers say when it shows up....

LFS
Author
21 May 2010 12:39 AM
Karl E. Peterson
Larry Serflaten wrote:
> "Karl E. Peterson" <k***@exmvps.org> wrote
>> Your clock is hosed.  Shouldn't you be -0500?
>
> Its just after 7:30 (CST is -6:00) as I post this.  I'll see what the
> servers say when it shows up....

Yep!   Date: Thu, 20 May 2010 19:32:07 -0600

But you're in CDT, which is -0500, not CST, right?  ;-)

That means, my posts that answer yours appear to have been made before
the ones they're replying to.

I'm in PDT now, which is -0700.

--
..NET: It's About Trust!  http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org
Author
21 May 2010 1:12 AM
Larry Serflaten
"Karl E. Peterson" <k***@exmvps.org> wrote

> Yep!   Date: Thu, 20 May 2010 19:32:07 -0600
>
> But you're in CDT, which is -0500, not CST, right?  ;-)

That stupid checkbox wasn't checked!

<g>
LFS
Author
21 May 2010 1:20 AM
Karl E. Peterson
Larry Serflaten wrote:
> "Karl E. Peterson" <k***@exmvps.org> wrote
>
>> Yep!   Date: Thu, 20 May 2010 19:32:07 -0600
>>
>> But you're in CDT, which is -0500, not CST, right?  ;-)
>
> That stupid checkbox wasn't checked!
>
> <g>
> LFS

I ask you, people...  Could a web forum *ever* be this fun?

--
..NET: It's About Trust!  http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org
Author
21 May 2010 9:06 AM
Dee Earley
On 21/05/2010 00:03, Tony Toews [MVP] wrote:
> Folks
>
> I came across the following line of code which errors out.
>
> If lrc<>  ERROR_NONE Then Error 5
>
> You can see examples of this code in MS KB articles.   For example
> http://support.microsoft.com/kb/210860
>
> This compiles but at execution time causes an error.  Now this isn't a
> big deal as the code is going to drop out of the routine anyhow.
>
> But I'm curious.  What is the Error 5 supposed to be doing?

Well I never, been using the language for 15+ years and I never noticed
that keyword...

--
Dee Earley (dee.ear***@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
Author
21 May 2010 3:20 PM
Jeff Johnson
"Dee Earley" <dee.ear***@icode.co.uk> wrote in message
news:%23Zd1WTM%23KHA.208@TK2MSFTNGP02.phx.gbl...

> Well I never, been using the language for 15+ years and I never noticed
> that keyword...

It was available in pre-visual versions of BASIC as well. If not that exact
keyword, at least the functionality. I know I could explicitly raise an
error in TRS-80 Color BASIC.
Author
21 May 2010 3:58 PM
Dee Earley
On 21/05/2010 16:20, Jeff Johnson wrote:
> "Dee Earley"<dee.ear***@icode.co.uk>  wrote in message
> news:%23Zd1WTM%23KHA.208@TK2MSFTNGP02.phx.gbl...
>
>> Well I never, been using the language for 15+ years and I never noticed
>> that keyword...
>
> It was available in pre-visual versions of BASIC as well. If not that exact
> keyword, at least the functionality. I know I could explicitly raise an
> error in TRS-80 Color BASIC.

Yeah, I was on QBasic before that and that predated my knowledge of
proper error handling or structured coding :)

--
Dee Earley (dee.ear***@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
Author
21 May 2010 8:55 PM
Tony Toews [MVP]
Dee Earley <dee.ear***@icode.co.uk> wrote:

>> If lrc<>  ERROR_NONE Then Error 5
>
>Well I never, been using the language for 15+ years and I never noticed
>that keyword...

Glad to read I'm not the only one.  <smile>

I replaced the Error 5 line with a Goto Exit routine.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/