On Winxp Pro
I try to trap an error:
On error resume next
If (Err.Number <> 0) Then
End sub
End If
but no matter what the case Err.Number = 0. When I was using visual basic
6.0 on a win2k pro computer, errors were returned with values other than 0.
Is there a patch I need to download or do I need to upgrade to VB.Net or
something? 10 6488
"aaron" <at******@yahoo .com> wrote in message
news:c4******** **@nntp6.u.wash ington.edu... On Winxp Pro I try to trap an error:
On error resume next If (Err.Number <> 0) Then End sub End If
but no matter what the case Err.Number = 0. When I was using visual basic 6.0 on a win2k pro computer, errors were returned with values other than
0. Is there a patch I need to download or do I need to upgrade to VB.Net or something?
"resume next" means exactly that.. continue with the next statement so it
can't catch errors (basically you are ignoring errors). What you might want
to do to catch errors is probably:
Sub SomeSub()
On Error GoTo ErrorHan
'code which may generate error
Exit Sub
ErrorHan:
Select Case Err.Number ' Evaluate error number.
Case xx 'handle it
Case 'etc
End Select
Resume
End Sub
On Wed, 31 Mar 2004 02:55:39 GMT, "Raoul Watson"
<Wa*****@Intell igenCIA.com> wrote:
<snip> "resume next" means exactly that.. continue with the next statement so it can't catch errors (basically you are ignoring errors). What you might want to do to catch errors is probably:
Sub SomeSub() On Error GoTo ErrorHan
'code which may generate error
Exit Sub
ErrorHan: Select Case Err.Number ' Evaluate error number. Case xx 'handle it Case 'etc End Select
Resume
Raoul, I totally disagree, both with what you say about
On Error Resume Next
and your 'improved' alternative
I suggest that you check out On Error Resume Next very carefully
- you will find that
a) it works
b) use of it makes simpler code
To the OP - try this
Private Sub Command1_Click( )
Dim I As Integer
On Error Resume Next
I = I / 0
If Err Then MsgBox Err.Description
End Sub
Thanks, with your hints I found that the problem is the error is not being
passed to my other function. How do I pass an error object or what is the
best way to pass an error if I want to pass both the description and the
number? I have:
Sub SomeSub()
On Error Resume Next
'code that generates error
If Err Then
MyError(Err) 'pass error object????
End If
End Sub
---------------------------
Sub MyError (MyErrorObject as ErrObject)
msgbox MyErrorObject.n umber 'it is always 0 because it's not being passed
End Sub
Thanks!
"J French" <er*****@nowher e.com> wrote in message
news:40******** ********@news.b tclick.com... On Wed, 31 Mar 2004 02:55:39 GMT, "Raoul Watson" <Wa*****@Intell igenCIA.com> wrote: <snip>
"resume next" means exactly that.. continue with the next statement so it can't catch errors (basically you are ignoring errors). What you might
wantto do to catch errors is probably:
Sub SomeSub() On Error GoTo ErrorHan
'code which may generate error
Exit Sub
ErrorHan: Select Case Err.Number ' Evaluate error number. Case xx 'handle it Case 'etc End Select
Resume
Raoul, I totally disagree, both with what you say about On Error Resume Next and your 'improved' alternative
I suggest that you check out On Error Resume Next very carefully - you will find that a) it works b) use of it makes simpler code
To the OP - try this
Private Sub Command1_Click( ) Dim I As Integer
On Error Resume Next I = I / 0 If Err Then MsgBox Err.Description
End Sub
"aaron" <at******@yahoo .com> wrote Thanks, with your hints I found that the problem is the error is not being passed to my other function. How do I pass an error object or what is the best way to pass an error if I want to pass both the description and the number? I have:
The Err Object is a global object. You should not pass it as a parameter.
The called sub will see the same error object that was present in the
caller routine. If you want to clear the error for use in your called sub,
then you will have to store the Err object values before you do anything
that would clear them out.
LFS
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
"J French" <er*****@nowher e.com> wrote in message
news:40******** ********@news.b tclick.com... On Wed, 31 Mar 2004 02:55:39 GMT, "Raoul Watson" <Wa*****@Intell igenCIA.com> wrote: <snip>
"resume next" means exactly that.. continue with the next statement so it can't catch errors (basically you are ignoring errors). What you might
wantto do to catch errors is probably:
Sub SomeSub() On Error GoTo ErrorHan
'code which may generate error
Exit Sub
ErrorHan: Select Case Err.Number ' Evaluate error number. Case xx 'handle it Case 'etc End Select
Resume
Raoul, I totally disagree, both with what you say about On Error Resume Next and your 'improved' alternative
I am not sure you read my post carefully.
1. My method is not "improved" that's a standard method. Even the VB help
file will show you a similar code for "on error". I have been using that
method over 25 years.
2. I never said On error resume next doesn't work, I use it all the time,
but like I said it resumes with the next statement so in essence "ignoring"
the error. For example:
On error resume next
open "filedoesntexis t" for input as #1
debug.print "we get here even if file doesn't exist".
I suggest that you check out On Error Resume Next very carefully - you will find that a) it works
See above.
Your method is fine too. I don't have a problem with you having the "last
word". er*****@nowhere .com (J French) wrote in message news:<40******* *********@news. btclick.com>...
<cut> Raoul, I totally disagree, both with what you say about On Error Resume Next and your 'improved' alternative
I suggest that you check out On Error Resume Next very carefully - you will find that a) it works b) use of it makes simpler code
I actually agree that it can make for simpler code and use it myself
(probably more often than I should). When recommending it you should
probably also note that
c) it adds overhead to the app and slows execution
d) it can mask bugs if you don't check for errors after any line that
might generate them
it's fine for short sections of code but not always best for longer
routines.
On Wed, 31 Mar 2004 22:30:20 GMT, "Raoul Watson"
<Wa*****@Intell igenCIA.com> wrote:
<snip> Your method is fine too. I don't have a problem with you having the "last word".
I really don't care - as long as you make an informed choice
On 31 Mar 2004 16:01:32 -0800, bu*******@earth link.net (Bob Butler)
wrote:
<snip> I actually agree that it can make for simpler code and use it myself (probably more often than I should). When recommending it you should probably also note that c) it adds overhead to the app and slows execution
... a tadd) it can mask bugs if you don't check for errors after any line that might generate them
Very true it's fine for short sections of code but not always best for longer routines.
That is a different subject - but I get your drift
It doesn't work.
If I do a debug.print Err.Number before I call the other function, it prints
out the error number correctly, but once I call the other function and try
to do a debug.print within that function I get a 0.
"Larry Serflaten" <Ab***@SpamBust ers.com> wrote in message
news:40******** @corp.newsgroup s.com... "aaron" <at******@yahoo .com> wrote Thanks, with your hints I found that the problem is the error is not
being passed to my other function. How do I pass an error object or what is
the best way to pass an error if I want to pass both the description and the number? I have:
The Err Object is a global object. You should not pass it as a parameter. The called sub will see the same error object that was present in the caller routine. If you want to clear the error for use in your called
sub, then you will have to store the Err object values before you do anything that would clear them out.
LFS
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =----- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Wing |
last post by:
I support an MS Access application in which errors are trapped using
the On Error statement. Just recently, the users of this system have
experienced run-time error number 3021 on a random basis. My biggest
problem right now is that the error description associated with this
error is Application-defined or object-defined error. It has always
been my understanding that these error numbers would not be used by
Microsoft and were available...
|
by: tom blower |
last post by:
Access 2k (10.6501.6714) SP3
For YEARS the code line "On Error Resume Next" has worked without any
problems. It is an essential tool. A couple of days ago, I put in
another hard drive, mentioned because the problems have arisen since
then, and transferred a lot of files, mainly MDB files, to the new
drive. This line of code now fails to work in all the databases I have
tried. I get error messages where none appeared before. I tried to...
|
by: tom blower |
last post by:
The Options are set OK.
What was wrong was that I had inadvertently set Error Trapping to 0. I
had been playing with this the other day.
Application.SetOption "Error Trapping", 2
on loading the startup form solves the issue. This should be a
standard line of code in all applicationsso that the issue is
controlled once the application is "out there".
|
by: Thelma Lubkin |
last post by:
I use code extensively; I probably overuse it. But I've been using
error trapping very sparingly, and now I've been trapped by that.
A form that works for me on the system I'm using, apparently runs into
problems on the system where it will actually be used, and since I
used so little error-trapping it dies very ungracefully.
I will of course try to fix whatever is causing the error and add
error-trapping to the functions where the...
|
by: Bill Stock |
last post by:
I have a subform which is causing a 3314 (Field can't contain a null value
because required is set to True) error. I solved this problem by trapping it
in the before update event. But then I started getting a "No Current Record"
error. I wanted to see what err number was coming through, so I put a MsgBox
in the subform's error event. But the MsgBox never came up and the error is
now gone.
Is the MsgBox pulling the focus away from the...
| |
by: Fred Nelson |
last post by:
I'm devloping a VB.NET web application and I'm having a problem with
trapping errors and logging the cause of them. When an unexpected error
occurs I want to write it to a file - or e-mail it to me. I have set up
everything according to the documentation however when I get to my error
page "errorpage.aspx" I can't determine why I'm there!
In my web.config file I have the line:
<customErrors ... defaultredirect="errorpage.aspx">
In...
|
by: Captain Nemo |
last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003.
I've recently added a piece of code to create an instance of Word, open a
document, fill in the blanks and become visible so the document can be
printed and/or modified.
This all takes place within one form, in which the Word.Application and
Word.Document objects are both private form-level variables. Just to be on
the safe side I included this piece of code in...
|
by: 47computers |
last post by:
Pretty new to PHP, I recently started learning about error trapping.
As of right now, I include the following into a page in my website:
-------BEGIN PASTE--------
error_reporting(E_ERROR | E_PARSE);
set_error_handler("SendErrorReport");
function SendErrorReport($errorNumber, $errorMessage, $errorFile,
$errorLine, $vars)
{
|
by: franc sutherland |
last post by:
Hello,
I am using Access 2003. I am having trouble trapping the "can't
append all the records in the append query" error message when
appending data to a query from a table which is linked to an excel
spreadsheet.
There are two tables. One is a list of general contacts, and the
other is a list of clubs. The clubs contain members who are within
the contacts table. When I add a list of new club members from the
|
by: GazK |
last post by:
I have been using an xml parsing script to parse a number of rss feeds
and return relevant results to a database. The script has worked well
for a couple of years, despite having very crude error-trapping (if it
finds an error in one of the xml files, the script stops). Recently, the
script has stopped working because one of the xml files is badly formed.
So I decided to rewrite the script with better error trapping; the
script should...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |