H
H
hellcaster2018-05-31 20:18:49
Visual Basic
hellcaster, 2018-05-31 20:18:49

What to do with Overflow in VBA?

There is this code:

Private Sub CommandButton2_Click()
Dim speed As Long, minute As Long, hour As Long, day As Long

speed = 299792
minute = 60 * speed
hour = (60 * 60) * speed
day = 60 * 60 * CLng(24)
day = CLng(day) * CLng(speed)

TextBox1.Text = minute
TextBox2.Text = hour
TextBox3.Text = day
End Sub

On line 8, an error pops up:
Run-time error '6':
Overflow

What to do?
(Line 8 is day = CLng(day) * CLng(speed))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question