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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dimensioning mulitple variable that are the same type

Status
Not open for further replies.

MinnKota

Technical User
Nov 19, 2003
166
US
I am pretty sure that I have seen somewhere how to dimension a number of variables (on one line) that are the same type. For instance...
Dim Name, Address, State as string

how is this done?
 
I have read somewhere that you generally don't want to do that. But..

Dim blah As String, blah3 As Variant, Yourmom As Field

would work. You don't have to stick with the same data type.

Problem is, if you are commenting on the variable, you can't when they are clumped together.

Mark P.

Bleh
 
that is not quite what I was looking for
 
What were you looking for?

This is much like doing an if then statement,
you can't write if x = 1 or 2 then,
you have to write if x = 1 or x = 2 then...

not to sound wierd, but often what we look for is not what we need.

Is this so that you can code faster, what's the purpose behind the question?



Mark P.

Bleh
 
I have read somewhere that you generally don't want to do that"

So if I understand correctly, this means that I can't do what I looking to do. I wanted to use the Dim function to dimension a whole mess of String variables, but I didn't want to type "string" after each of them.
 
Well, what i'm saying is solution that I gave you isn't usually what people use. You could do it, but from what I have read it's not a good coding technique.
And you definately can't do what you are wanting to do.

Now, if you don't care if if the variable is considered a variant, you don't have to declare them at all. Also this isn't considered good coding, but you can do it. Variants take up more memory, so you'll just have to weigh that in your decision making.





Mark P.

Bleh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top