On Error ... Fails! - Any suggestions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    #1

    On Error ... Fails! - Any suggestions

    Hi,

    I've got some code which uses various "On Error" statements to try to trap
    some errors in VB6. When I try it on one machine (WinXP SP1) it works fine,
    but on another machine (WinXP SP2) it fails to trap the error and so the
    code fails. e.g.


    On Error Resume Next
    debug.print 3/0

    Would fail on the "debug" line.

    On Error Goto Fred
    debug.print 3/0
    Fred:

    would also fail on the "debug" line

    Any suggestions??

    Without this basic error trapping the whole application is screwed.

    Thanks

    Andy


  • Steve Gerrard

    #2
    Re: On Error ... Fails! - Any suggestions


    "Andy" <a@a.com> wrote in message
    news:d6d3ol$ja0 $1@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...[color=blue]
    > Hi,
    >
    > I've got some code which uses various "On Error" statements to try to trap
    > some errors in VB6. When I try it on one machine (WinXP SP1) it works fine,
    > but on another machine (WinXP SP2) it fails to trap the error and so the
    > code fails. e.g.
    >
    >
    > On Error Resume Next
    > debug.print 3/0
    >
    > Would fail on the "debug" line.
    >[/color]

    Right click on your code somewhere, choose Toggle, and select "Break on
    Unhandled Errors".


    Comment

    • Raoul Watson

      #3
      Re: On Error ... Fails! - Any suggestions


      "Andy" <a@a.com> wrote in message
      news:d6d3ol$ja0 $1@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...[color=blue]
      > Hi,
      >
      > I've got some code which uses various "On Error" statements to try to trap
      > some errors in VB6. When I try it on one machine (WinXP SP1) it works[/color]
      fine,[color=blue]
      > but on another machine (WinXP SP2) it fails to trap the error and so the
      > code fails. e.g.
      >
      >
      > On Error Resume Next
      > debug.print 3/0
      >
      > Would fail on the "debug" line.
      >
      > On Error Goto Fred
      > debug.print 3/0
      > Fred:
      >
      > would also fail on the "debug" line
      >
      > Any suggestions??
      >
      > Without this basic error trapping the whole application is screwed.
      >
      > Thanks
      >
      > Andy
      >[/color]

      I believe the debug.print would be outside your program scope. Does it
      handle it correctly if you do:

      On Error Resume Next
      x = 3/0
      Debug.Print "The error handler worked"


      Comment

      • Andy

        #4
        Re: On Error ... Fails! - Any suggestions---Thanks

        That solved it - after all these years with vb, I'd never had the need to
        use that option.

        Thanks

        Andy


        "Steve Gerrard" <mynamehere@com cast.net> wrote in message
        news:0LmdnWc3Yp 63BBffRVn-iQ@comcast.com. ..[color=blue]
        >
        > "Andy" <a@a.com> wrote in message
        > news:d6d3ol$ja0 $1@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...[color=green]
        > > Hi,
        > >
        > > I've got some code which uses various "On Error" statements to try to[/color][/color]
        trap[color=blue][color=green]
        > > some errors in VB6. When I try it on one machine (WinXP SP1) it works[/color][/color]
        fine,[color=blue][color=green]
        > > but on another machine (WinXP SP2) it fails to trap the error and so the
        > > code fails. e.g.
        > >
        > >
        > > On Error Resume Next
        > > debug.print 3/0
        > >
        > > Would fail on the "debug" line.
        > >[/color]
        >
        > Right click on your code somewhere, choose Toggle, and select "Break on
        > Unhandled Errors".
        >
        >[/color]


        Comment

        Working...