overflow problem in vb6

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?
isnoend2001Asked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
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
 
Shaun KlineLead Software EngineerCommented:
You would need to change your variable declaration from Integer to Long.
0
 
isnoend2001Author Commented:
It already is
 Public gTotalRuns As Long
0
 
Shaun KlineLead Software EngineerCommented:
You may have to cast the 1 to a long.

gTotalRuns = gTotalRuns + CLng(1)

Open in new window

0
 
isnoend2001Author Commented:
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
All Courses

From novice to tech pro — start learning today.