-
April 7th, 2007, 05:21 AM
#1
VBA with Excel:Declaring string variable
I am comparatively new to VBA programming.Till now, all the variables I have used were of type "Dim".
I now have to use a string variable in VBA.How to declare a string variable?
The variable may have a value "DL" or "LL".It needs to be one dimensional array variable.
Please , please help!!
-
April 7th, 2007, 06:35 AM
#2
Re: VBA with Excel:Declaring string variable
Dim isn't a Type, it tells to VB to dimension a variable as a particular type, e.g. for a string:
Code:
Dim MyVariable As String
since you've been omitting a Type in your declarations VB has been declaring them as Variants - which are slow and use more memory, e.g.
Code:
' these are the same thing
Dim MyVariable
Dim MyVariable As Variant
-
April 7th, 2007, 12:10 PM
#3
Re: VBA with Excel:Declaring string variable
Can I have:
Dim MyVariable(10) as string
And then,
MyVariable = "DL"
Should I put the value of the variable in double codes?
-
April 7th, 2007, 01:07 PM
#4
Re: VBA with Excel:Declaring string variable
With a string array you can have
MyVariable(0) = "DL" thru MyVariable(10) = "DL"
or, 11 dimensions of the array. You can use multi-dimensional arrays as well. arr(2,3,4)=33
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|