Quote:
> I have recently written an application with events that pass arrays by
> reference to functions within modules. These functions then redimension
> and populate the arrays.
> Question: I have had difficulty casting arrays to specific types. For
> example, consider the following:
> Form Level:
> SUB Button1_Click(..)
> Static theArray$()
> DoWhatever theArray$
> END SUB
> Module Level:
> SUB DoWhatever (anArray())
> ReDim Preserve anArray(2,2)
> anArray(1,1) = "Charlie"
> ....(etc)
> END SUB
> When I try to pass the STRING array to the DoWhatever subroutine, I get
> what amounts to a "wrong type" message. I tried wrapping the theArray$
> array with CVar(), but that didn't work.
> Any ideas?
> TIA. --- Dave
DoWhatEver should look like
Sub DoWhatever(AnArray() as String)
ReDim Preserve AnArray(2,2) as String
....
Also note that only the last dimension can be changed with Preserve.
Specifically lets say you have 100 Addresses, each address consisting
of say Street,City,PostCode. Then you would set up the array as follows:
Redim Address(3,100) as String
where Address(1,N) = Street
Address(2,N) = City
Address(3,N) = Postcode
Now when you want to add a entry you do:
Redim Preserve Address(3,101) As String
--
[ Name : Daniel Grealy ]