ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determining Variable Declaration (https://www.excelbanter.com/excel-programming/381513-determining-variable-declaration.html)

Tim Childs

Determining Variable Declaration
 
Hi

it may sound a bit strange but is it possible to find, given a variable
name, how it has been declared e.g. string, double etc

i.e without simply finding the declaration statement

thanks

Tim



JE McGimpsey

Determining Variable Declaration
 
Take a look at the TypeName method in XL/VBA Help


In article ,
"Tim Childs" wrote:

Hi

it may sound a bit strange but is it possible to find, given a variable
name, how it has been declared e.g. string, double etc

i.e without simply finding the declaration statement

thanks

Tim


Tim Childs

Determining Variable Declaration
 
Hi

yes that does the trick - THANKS

Is it possible to determine in a similar way the scope of the declaration
e.g. whether it was a Dim or Public etc?
(Last question (today) - I won't bother you again!)

Thanks

Tim


"JE McGimpsey" wrote in message
...
Take a look at the TypeName method in XL/VBA Help


In article ,
"Tim Childs" wrote:

Hi

it may sound a bit strange but is it possible to find, given a

variable
name, how it has been declared e.g. string, double etc

i.e without simply finding the declaration statement

thanks

Tim




Tim Childs

Determining Variable Declaration
 
Hi

that is neat - THANKS

Tim

"John Bundy" (remove) wrote in message
...
Does this do what you want

Find a Variable Definition


To view the definition of a variable

In the Code window, select the variable whose definition you want to see.


From the View menu, choose Definition (SHIFT+F2).
To return the mouse pointer to its previous position

On the View menu, click Last Position (CTRL+SHIFT+F2).

--
-John Northwest11
Please rate when your question is answered to help us and others know what
is helpful.


"Tim Childs" wrote:

Hi

it may sound a bit strange but is it possible to find, given a

variable
name, how it has been declared e.g. string, double etc

i.e without simply finding the declaration statement

thanks

Tim






Tim Childs

Determining Variable Declaration
 
Hi

Thanks

I do that but on a large Project the variables seem to have multiplied and
many have similar names e.g. I have declared sMsg in several places and want
to get to see what is non-null at the end of the project

Hope that makes some sort of sense :)

TIm

"Jim Thomlinson" wrote in message
...
Generally speaking when you declare variables there are some standards to
follow. Some people use the 1 letter prefix while others use a 3 letter
prefix. That prefix is there to define the declaration type of the

variable.
For example

dim sMyName as String
or
dim strMyName as String

Declare your variables that way and you will never wonder again... Take a
look at the code posted by most of the MVP and similar and you will notice
these naming conventions being used...
--
HTH...

Jim Thomlinson


"Tim Childs" wrote:

Hi

it may sound a bit strange but is it possible to find, given a

variable
name, how it has been declared e.g. string, double etc

i.e without simply finding the declaration statement

thanks

Tim







All times are GMT +1. The time now is 05:22 PM.

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