Link to home
Start Free TrialLog in
Avatar of cossy74
cossy74

asked on

VB and errors

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?
Avatar of [ fanpages ]
[ fanpages ]

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.

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
PS. Err.Clear is not needed, as 'On Error Resume Next' resets the Err object anyway.
Avatar of cossy74

ASKER

fanpages: I change ot your code and still the same thing any suggestion
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.
ASKER CERTIFIED SOLUTION
Avatar of [ fanpages ]
[ fanpages ]

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the points/grading.

BFN,

fp.
[ http://NigelLee.info ]