Results 1 to 13 of 13

Thread: I am getting Runtime Error 16

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    507

    I am getting Runtime Error 16

    Hi guys

    I am getting a Runtime Error 16: Overflow. when my EXE that I created in VB 6 is running for few minutes and when I Click ok on the OK Button on error msg, the application shut down.

    Any idea what could be the cause?

    Thanks

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: I am getting Runtime Error 16

    The overflow error means that you are trying to put a number into a variable (or property etc), but the value is too high - such as 33000 into an Integer variable.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: I am getting Runtime Error 16

    What does your application do?

    Does this happen in the IDE or only in the compiled version?

  4. #4

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    507

    Re: I am getting Runtime Error 16

    When this runs it gives the user a choice to delay a reboot of his computer, when he choses to delay, after few minutes I would say about 10 min , this errors kicks in, If I run the EXE without clicking on the Command2, it works well.


    Here is the Code:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim startTime As String
    3.     Dim minutesToDelay As String
    4.         With Timer1
    5.             .Interval = 1
    6.             .Enabled = True
    7.         End With
    8.             myApp = "shutdown.exe -r"
    9.             startTime = CStr(timeGetTime)
    10.             minutesToDelay = "5" 'must be a number character, otherwise Val returns 0
    11.             endTime = Val(startTime) + Val(minutesToDelay * 60000)
    12.             SetWindowPos Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    13.             Me.WindowState = vbMinimized
    14.             delayCount = delayCount + 1 'increase delay counter for 1
    15.         If delayCount = 5 Then 'if you want to limit number of delays
    16.             Shell "shutdown -a"
    17.             Sleep 1200
    18.             Shell "shutdown -f -r -t 300 -c ""Your machine will reboot in 5 minutes"""
    19.                
    20.          
    21.         End If
    22.                                      
    23. End Sub
    24.  
    25. Private Sub Form_Load()
    26.     ' Timer1.Interval = 100   'fire timer
    27.     Timer1.Enabled = True
    28.     Timer1.Interval = 60000 '1 minute
    29. End Sub
    30.  
    31. Private Sub Picture1_Click()
    32.  
    33. End Sub
    34.  
    35. Private Sub Timer1_Timer()
    36. Static iCounter As Integer
    37.  
    38.     If iCounter = 3600000 Then
    39.         SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    40.             Me.WindowState = vbNormal
    41.         iCounter = 0
    42.     End If
    43.     iCounter = iCounter + 1
    44.      
    45.  
    46. End Sub

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    507

    Re: I am getting Runtime Error 16

    by the way ,this is part of the code where I think where the problem is

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: I am getting Runtime Error 16

    As RhinoBull said, you need to declare the variable as Long (max value over 4 billion) rather than Integer (max value just over 32000), ie:
    VB Code:
    1. Static iCounter As [u]Long[/u]

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    507

    Re: I am getting Runtime Error 16

    I will try this out

  9. #9
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    342

    Re: I am getting Runtime Error 16

    Isn't Long a max of just over 2 billion?

    Double is bigger... (but long should do for what he needs)....

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    507

    Re: I am getting Runtime Error 16

    ok now, I am not getting the error msg anymore, but it seems its NOT calling the task that it supposed to every 60 mins. changing it to LONG do I have to change the format of the number to reflect 60 min, in another words ,what number I need to put in the iCounter to reflect 60 min?

    VB Code:
    1. Private Sub Form_Load()
    2.     ' Timer1.Interval = 100   'fire timer
    3.     Timer1.Enabled = True
    4.     Timer1.Interval = 60000 '1 minute
    5. End Sub
    6.  
    7. Private Sub Picture1_Click()
    8.  
    9. End Sub
    10.  
    11. Private Sub Timer1_Timer()
    12. Static iCounter As Long
    13.  
    14.     If iCounter = 3600000 Then
    15.         SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    16.             Me.WindowState = vbNormal
    17.         iCounter = 0
    18.     End If
    19.     iCounter = iCounter + 1
    20.      
    21.  
    22. End Sub
    Last edited by wajdi; Aug 25th, 2006 at 12:56 PM.

  11. #11

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    507

    Re: I am getting Runtime Error 16

    Thanks let me try it out

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: I am getting Runtime Error 16

    Quote Originally Posted by tward_biteme1
    Isn't Long a max of just over 2 billion?
    Yep.. silly me!

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