LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default String variables

See inline comments...


Okay... I don't really feel that was necessary to answer the question.


Well, if you had any reason at all for including the last paragraph in your
original posting, then you are wrong... your actual code is quite material
to helping with that part of your message.


does:

Dim ThisVar as String
ThisVar = "ABCDEF"

take more memory than this:

Dim ThisVar as String * 6
ThisVar = "ABCDEF"


If you really think you need to see an answer to the above question, here is
how Microsoft describes it a this link...

http://msdn.microsoft.com/en-us/library/dd942824.aspx

Declare String Data Intelligently
================================================== ======
Visual Basic allocates stack and heap memory differently according to the
type of strings you create. By understanding how this works, you can write
more efficient string code. String variables in procedures that are
non-static use space on the computer's stack. Use the following information
to write code that minimizes stack memory usage.

Local fixed-length strings less than or equal to 64 characters use 2 bytes
for each character in the string. They don't use heap memory.

Local fixed-length strings longer than 64 characters use 4 bytes of stack
memory for a pointer to the variable in heap memory and 2 bytes of heap
memory for each character in the string.Local variable-length strings use 4
bytes of stack memory for a pointer to the variable in heap memory, and a
variable amount of heap memory according to the length of the string.

If your code used a large number of fixed-length strings of 64 characters or
less, you can reduce stack usage by changing the strings to local
variable-length strings or making them static fixed-length strings.


The entirety of the code in question is 221 lines long, and no, this is
not
a direct excerpt. A direct excerpt isn't necessary to answer the
question,
since the question is not about code, but how Excel handles variable
declaration.


Again, I have to wonder why you went out of your way to include the last
paragraph in your original posting. Variable memory usage is not where long
processing time comes from... it comes directly from the method of coding
used to process the strings (no matter whether they are fixed or variable in
length).


--
Rick (MVP - Excel)

 
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
Call Variables by String Thomas [PBD] Excel Programming 1 July 15th 08 02:10 PM
Call Variables by String Thomas [PBD] Excel Programming 0 July 15th 08 01:20 PM
String variables John New Users to Excel 3 July 16th 06 09:08 PM
Parse String into Variables Gary''s Student Excel Programming 3 September 21st 05 03:32 PM
String Variables [email protected] Excel Programming 1 August 30th 03 07:28 AM


All times are GMT +1. The time now is 11:48 PM.

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"