Re: Declaration problem
- From: Simon Murphy <Simon.Murphy.1u7gqd_1124780762.3753@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 23 Aug 2005 01:38:37 -0500
David
sorry I should have been clearer
x is not overflowing, the result of your formula is overflowing. The
issues isn't so much what x can and can't do, but how VB guesses the
data type of a formula result. (hence why 38000-8000 fixes it)
effectively you are taking a short cut from this:
result = x*30000
Cells(x, 1).Value = result
The question is what is the type of result?
answer: most programming languages assume the largest data type of any
of the arguments, which is why changing one to a long fixes it.
If you replace your short version with the 2 lines above and dim result
as a long then the problem is still there. VB internally apparently
can't calculate x*30000 where x is an int >1.
So your observation is right - the data type does have a big impact on
what can be done with a variable, and part of that is how VB guesses
the data type of a formula result, based on the data type of all the
arguments
I rarely use ints anyway in VBA, I mainly use longs.
cheers
Simon
--
Simon Murphy
------------------------------------------------------------------------
Simon Murphy's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26538
View this thread: http://www.excelforum.com/showthread.php?threadid=398008
.
- Follow-Ups:
- Re: Declaration problem
- From: davidm
- Re: Declaration problem
- References:
- Declaration problem
- From: davidm
- Re: Declaration problem
- From: Simon Murphy
- Re: Declaration problem
- From: davidm
- Declaration problem
- Prev by Date: RE: Setting up a simple loop to fill labels?
- Next by Date: Re: Extract only non-matching data
- Previous by thread: Re: Declaration problem
- Next by thread: Re: Declaration problem
- Index(es):
Relevant Pages
|