[AccessD] The ARRAY function

Charlotte Foust cfoust at infostatsystems.com
Wed Dec 17 19:57:26 CST 2003


If you want to use a variable, use Split instead of Array().  Then you
don't need all those extra chr(34)s, etc.

Public Function TestArray()
    Dim strStuff As String
    Dim vararray As Variant
    strStuff = "Tom, Dick, Harry"
    Debug.Print strStuff
    ' Run the Split function to place the contents of the string into an
array.
    vararray = Split(strStuff, ",")
    Debug.Print vararray(0)

End Function

Charlotte Foust

-----Original Message-----
From: Jim Lawrence (AccessD) [mailto:accessd at shaw.ca] 
Sent: Wednesday, December 17, 2003 5:28 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] The ARRAY function


Hi All:

I am running in some strange responses, maybe too much chocolate has
fuddled the brain but:

Given the following:
' Set strStuff
strStuff = chr(34) & "Tom" & chr(34) & ", " & chr(34) & "Dick" & chr(34)
& ", " & chr(34) & "Harry" & chr(34) ' Print strStuff ? strStuff "Tom",
"Dick", "Harry" ' Run the ARRAY function to place the contents of the
string into an array. varArray = Array(strStuff) ? varArray(0) ' Print
the first index. "Tom", "Dick", "Harry" ' OK ????? ' Now type in the
same information manually or cut and paste... varArray = Array("Tom",
"Dick", "Harry") ? varArray(0) ' and the results are what they should
be. Tom

What is going on and why can a variable not be used in the ARRAY
function?? :-(

Any suggestions would be greatly appreciated.
Jim

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


More information about the AccessD mailing list