Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which veriable takes the least memory ????

Status
Not open for further replies.

Toyman

Programmer
Jun 19, 2001
68
GB
I have an text box that I want to reference in a class.

1 : I can dim a veriable by its name e.g
Dim MyTextBox as String
MyTextBox = "Text1"

or

2 : I can pass the object e.g
Dim MyTextBox as Control
Set MyTextBox = Text1

Which veriable takes the least memory 1 or 2

 
Some confusion in your example, as the second does not have (or at least show) a value for Text1 (it is NOT shown as a string).

In general, the second approach only creates a reference to the existing object. I THINK this is a long, which would be four bytes. The first declares a string variable which occupys one byte for each character and some overhead, so "Text1" is more than 5 bytes.

BUT ... ,

You STILL need the string to be instantiated somewhere, so the 5+ bytes are within the program space.

In a more general response, I think the answer need to be more along the lines of:

"It depends more on the overall application architecture than the individual instance of your example".

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top