[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB and errors

Posted on 2005-04-11
7
Medium Priority
?
152 Views
Last Modified: 2011-09-20
Hi

currently i have this peice of code:
  On Error Resume Next
  Err.Clear
  Call oServer.Connect(m_sSystem, m_sUsername, m_sPassword)
      Call DBGValue("Err.Number", Err.Number)
      Select Case Err.Number
        Case "70"
            Call DBG("Permission Denied")
        Case "0"
            Call DBG("No Error")
        Case Default
            Call DBG("Has Error")
      End Select

My problem is this the DBGValue show me the Err.Number is 70 but the Case statement show the Number being 0
what is happening?
0
Comment
Question by:cossy74
  • 6
7 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 13758465
I do not know what Call DBGValue(...) function does, but Err.Number is defined as a Long data type.

Your Case statements are checking for Strings; try changing Case "70" to Case 70, & Case "0" to Case 0.

BFN,

fp.

0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 13758469
e.g.

 On Error Resume Next
  Err.Clear
  Call oServer.Connect(m_sSystem, m_sUsername, m_sPassword)
      Call DBGValue("Err.Number", Err.Number)
      Select Case Err.Number
        Case 70
            Call DBG("Permission Denied")
        Case 0
            Call DBG("No Error")
        Case Default
            Call DBG("Has Error")
      End Select
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 13758474
PS. Err.Clear is not needed, as 'On Error Resume Next' resets the Err object anyway.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:cossy74
ID: 13758545
fanpages: I change ot your code and still the same thing any suggestion
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 13758568
Please post the code that relates to the DBGValue() function.

Do you use an 'On Error...' statement within this function, because if you do, Err.Number will be reset to 0.

BFN,

fp.
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 2000 total points
ID: 13758576
Try this as a test:

Dim lngErr_Number As Long

  On Error Resume Next

  Call oServer.Connect(m_sSystem, m_sUsername, m_sPassword)

  lngErr_Number = Err.Number

   Call DBGValue("Err.Number", lngErr_Number)

  Select Case lngErr_Number
        Case 70
            Call DBG("Permission Denied")
        Case 0
            Call DBG("No Error")
        Case Default
            Call DBG("Has Error")
  End Select


Let me know if this is any different... but providing the code to DBGValue() will help me further.

BFN,

fp.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 13760044
Thanks for the points/grading.

BFN,

fp.
[ http://NigelLee.info ]
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question