"dim" problem after Service Pack Installation????

G

Guest

Today, I have this strange problem of dim. I don't have this problem before.
If I run the following program, variable d would automatically round up to
an integer. This happens to me any variable that I put at the end of the dim
statement if I have two or more variables.

Sub Button1_Click()
Dim a, b, c, d As Long
a = Range("c3")
b = Range("c3")
c = Range("c3")
d = Range("c3")
Range("c5") = a
Range("c6") = b
Range("c7") = c
Range("c8") = d
End Sub
 
D

Dave Peterson

This line:

Dim a, b, c, d As Long

Really is the same as:

Dim a as variant
Dim b as variant
Dim c as variant
Dim d As Long

Longs are positive and negative (and 0) whole numbers. They don't contain
fractions.

Did you want

Dim a as double
dim b as double
dim c as double
dim d as double

or equivalently

dim a as double, b as double, c as double, d as double
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top