ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Declaring variables (Long, String, Integer) and interpretation spe (https://www.excelbanter.com/excel-programming/318770-declaring-variables-long-string-integer-interpretation-spe.html)

mrt

Declaring variables (Long, String, Integer) and interpretation spe
 
Dear Colleagues,

Does anyone know which one of the two following ways to declare a string is
faster for the VBA engine to read/interpret

1 = Dim MyVar$
1 = Dim MyVar as String

Thanks,

Mr. T


Bob Phillips[_6_]

Declaring variables (Long, String, Integer) and interpretation spe
 
If either is actually faster, which I doubt as they are both just reserving
memory space, it will be insignificant.

What you do in the code itself will be far more important in terms of
speed/performance.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"MrT" wrote in message
...
Dear Colleagues,

Does anyone know which one of the two following ways to declare a string

is
faster for the VBA engine to read/interpret

1 = Dim MyVar$
1 = Dim MyVar as String

Thanks,

Mr. T




Jerry W. Lewis

Declaring variables (Long, String, Integer) and interpretation spe
 
In terms of working with the variables in the body of the program, all
else being equal, I would expect that working with a specific data type
would be faster than working with a variant (which is what you get when
you don't specify a type).

It is also possible that working with Long may be faster than Integer
and Double may be faster than Single, if VBA coerces them to the longer
type for arithmetic operations and then back again.

Jerry

Bob Phillips wrote:

If either is actually faster, which I doubt as they are both just reserving
memory space, it will be insignificant.

What you do in the code itself will be far more important in terms of
speed/performance.



Bob Phillips[_6_]

Declaring variables (Long, String, Integer) and interpretation spe
 
Jerry,

What you say is absolutely correct, but has no bearing. Dim MyVar$ and Dim
MyVar as String are both specific data types, both strings.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jerry W. Lewis" wrote in message
...
In terms of working with the variables in the body of the program, all
else being equal, I would expect that working with a specific data type
would be faster than working with a variant (which is what you get when
you don't specify a type).

It is also possible that working with Long may be faster than Integer
and Double may be faster than Single, if VBA coerces them to the longer
type for arithmetic operations and then back again.

Jerry

Bob Phillips wrote:

If either is actually faster, which I doubt as they are both just

reserving
memory space, it will be insignificant.

What you do in the code itself will be far more important in terms of
speed/performance.





Jerry W. Lewis

Declaring variables (Long, String, Integer) and interpretation spe
 
So much for speed reading comphrehension as I am about to walk out the
door. Ouch :-(

Bob Phillips wrote:

Jerry,

What you say is absolutely correct, but has no bearing. Dim MyVar$ and Dim
MyVar as String are both specific data types, both strings.




All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com