[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

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?
0
isnoend2001
Asked:
isnoend2001
  • 2
  • 2
1 Solution
 
Shaun KlineLead Software EngineerCommented:
You would need to change your variable declaration from Integer to Long.
0
 
GrahamSkanCommented:
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
 
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now