Discussion Locked

Visual Basic 6.0 help

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm getting an error Run time error '6' overflow.
Help me!! Tell me what's wrong.

Private Sub cmdbutton_Click()
Dim population As Integer
Dim years As Integer
years = 0
population = 6000000
Do While population > 10000000
population = population * 0.014
years = years + 1
Loop
picWhen.Print "In"; years; "Population will be"; population;
End Sub

4 replies

by rubenbenjamin

Dear Friend,
It is very simple

Integers can only hold values for a certian range as in C.

declare it as a double

Private Sub cmdbutton_Click()
Private Sub Form_Load()
Dim population As Double
Dim years As Integer
years = 0
population = 6000000
Do While population > 10000000
population = population * 0.014
years = years + 1
Loop
MsgBox "In" & years & "Population will be" & population
End Sub

by pendyala.subbarao

Please do this:
Private Sub cmdbutton_Click()
Dim population As Integer
Dim years As Integer
years = 0
population = 6000000
Do While population > 10000000
population = population * 0.014
years = years + 1
Loop
Print "In"; years; "Population will be"; population;
End Sub

This discussion is closed to new replies.