Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lucas Ward   on Mar 25 In MS Office Category.

  
Question Answered By: Tasha Wheeler   on Mar 25

Conversion in VBA is actually pretty simple:
Dim A as Integer, B as Integer, C as Long

C=CLng(A)*CLng(B)

What's wrong here, though, is this method won't save memory. It will
actually increase the consumption by creating 2 new mem assignments of
Type Long and holding the output of converting A and B to Long for
whatever amount of cycles is necessary to populate C.

So the thing I have to ask is why and how are you in a position where
you've run  out of memory for simply declaring A and B as Long in the
first place?

Contrary to popular advice, the use of Variant variables  is not
something you should avoid entirely. Often, if I think I'm in memory
trouble, I go ahead and rescope everything to variant just to check
whether my memory problems are real. I don't trust the actual generated
answers, don't get me wrong. I'm just checking to see if my memory
problem still exists. If it doesn't, I'm doing something else wrong in
my code which is causing an apparent memory issue. Why?

Because any 32 bit application running in Windows believes it has 2 Gigs
of memory to work in. Windows itself builds this lie and presents it to
the application while managing the real memory in the background. Even a
system populated with only 64 megs of RAM will still tell each running
application that it has 2 gigs to work in. Consuming all 2 Gigs is an
accomplishment. Odds are against you having truly consumed that virtual
memory.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 


Tagged: