Results 1 to 3 of 3

Thread: Error Trapping(Variable Overflow)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Angry

    Im trying to make a error
    handler for my program for
    a overflow, err.number 6
    Can someone tell me why this
    doesnt work?

    Code:
     
    Public Number As Integer
    
    Private Sub Form_Load()
    ErrorTrapper
    End Sub
    
    Private Sub ErrorTrapper()
    On Error GoTo ErrorHandler   ' Enable error-handling routine.
    Number = 2.21222222222222E+27
    Exit Sub      ' Exit to avoid handler.
    ErrorHandler:   ' Error-handling routine.
       Select Case Err.Number   ' Evaluate error number.
          Case 6   ' "Res Index not there" error.
          Exit Sub
       End Select
    End Sub
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    First the error occurred as your integer can't support that large number (2^15-1 is the highest)

    Second your errorhandler don't work because you have err.number
    Use only err

    Third you should use a resume statement to get back from your procedure
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Talking

    I was trying to cause the error
    It wasnt what you said though..
    For future ref. If somebody asks this
    question make should there vb is set to
    break on unhandled errors, not ALL errors.

    Thanks

    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width