[AccessD] Array questions

Stuart McLachlan stuart at lexacorp.com.pg
Tue Jan 17 15:28:34 CST 2023


In your recent post you said:
<quote>
At the top of a module is an array declaration:
Dim arrLetters() as String
</quote/
If you are going to populate it with = ARRAY(....), then it must de
Dim arrLetters as Variant
not String, and no "()"


On 17 Jan 2023 at 14:38, Arthur Fuller wrote:

> That much is obvious, Stuart. But I can't figure out why declaring the
> array at the top of the module, outside of any sub or function,
> doesn't work.
> 
> On Mon, Jan 16, 2023 at 11:52 PM Stuart McLachlan
> <stuart at lexacorp.com.pg> wrote:
> 
> > Or, if you can keep track of what is going on and what sort of
> > values you are working with and want to take the performance hit,
> > you *could* use a variant (Bleccchhhh!) It works for any variable
> > type, not just strings
> >
> > Dim v As Variant
> > v = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
> > Dim a() As Long
> > Debug.Print v(4) ' returns 5 - resultant array is zero based!
> >
> >
> > On 17 Jan 2023 at 14:39, Stuart McLachlan wrote:
> >
> > > On 17 Jan 2023 at 10:09, Stuart McLachlan wrote:
> > >
> > > > Nor can you assign a collection of values to multiple array
> > > > elements. in one statement.
> > > >
> > >
> > > I forgot the SPLIT function :)
> > > You can as long as the array has not been dimensioned!
> > >
> > > 'Next line is not needed if you don't use Option Explicit - but
> > > that is NOT advised Dim a() As String ' DO NOT DIMENSION if you
> > > are going to use SPLIT
> > >
> > > Dim s As String
> > > s = "One,Two,Three,Four,Five,Six,Seven,Eight,Nine,Ten"
> > > a() = Split(s, ",")
> > > Debug.Print a(4) ' returns Five - resultant array is zero based!
> > > -- AccessD mailing list AccessD at databaseadvisors.com
> > > https://databaseadvisors.com/mailman/listinfo/accessd Website:
> > > http://www.databaseadvisors.com
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> 
> 
> -- 
> Arthur
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list