Solved

overflow problem in vb6

Posted on 2013-11-15
5
352 Views
Last Modified: 2013-11-15
i have a counter to track how many times program has run:
declared like this:
Public gTotalRuns As Long
In the sub
70        gTotalRuns = gTotalRuns + 1

gives the error::
Overflow
line 70
gTotalRuns = 32,768
How can i fix this?
0
Comment
Question by:isnoend2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39651529
You would need to change your variable declaration from Integer to Long.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 39651555
Have you accidentally left a local declaration in the Sub, like this?
Public gTotalRuns As Long

Sub MySub()
    Dim gTotalRuns As Integer

    '...
    gTotalRuns = gTotalRuns + 1
    '...
End Sub

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 39651556
It already is
 Public gTotalRuns As Long
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 39651576
You may have to cast the 1 to a long.

gTotalRuns = gTotalRuns + CLng(1)

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 39651609
Thanks you got me looking closer and I had an integer value on the next line
I was looking at the wrong line number(I Think)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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