Declaring an array

davesmith202

Employee of Access World
Local time
Today, 19:18
Joined
Jul 20, 2001
Messages
522
I have the following code:

Code:
Dim var
    var = Split(strPGNdata, vbCrLf)

Since I know it is string data, should I somehow define what type of variable the var is?

Thanks,

Dave
 
By not defining the datatype Access has to decide itself based on the contents if finds. So you can prement it by declaring it as a string to save a smidgen of time. Also if you know the number of elements in the array this will also help.
 
If you don't provide a datatype in the Dim statement, I believe VBA creates a Variant by default, initialized to the value 'Empty'.
Also, I think the Split function returns a variant array. If you try to assign this return value to a string or an existing array I'd expect to get an error. It needs to be assigned to a variant.
I would leave that code just as it stands.
Cheers,
 
Ahhh that's why. I asked because I got an error when I tried to define it as a string.
 
I stand corrected regarding array declarations.
 

Users who are viewing this thread

Back
Top Bottom