[AccessD] Array questions

Arthur Fuller fuller.artful at gmail.com
Tue Jan 17 13:38:30 CST 2023


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


More information about the AccessD mailing list