Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default "dim" problem after Service Pack Installation????

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default "dim" problem after Service Pack Installation????

You have made a classic mistake in your dim statements. Only d is a long the
rest of the variables are of type variant. Check out this link...

http://www.cpearson.com/excel/variables.htm

Darn near everything you need to know about declaring variables is right here.
--
HTH...

Jim Thomlinson


"Kensyo" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default "dim" problem after Service Pack Installation????

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



Kensyo wrote:

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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CHANGE THE RIBBON AFTER THE INSTALLATION OF ADDIN "MOREFUNC" FARAZ QURESHI Excel Discussion (Misc queries) 0 May 19th 09 03:31 PM
Excel Service error "cannot connect to external data source" Jooho Excel Discussion (Misc queries) 1 October 30th 06 11:08 PM
I am receiving "prepare for installation" message when I try to . Jo Excel Discussion (Misc queries) 0 March 31st 06 06:21 PM
Difference between a Service Release and a Service Pack? Bill Renaud[_2_] Excel Programming 2 April 16th 04 04:13 AM


All times are GMT +1. The time now is 11:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"