[AccessD] Array questions

Stuart McLachlan stuart at lexacorp.com.pg
Mon Jan 16 22:52:15 CST 2023


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
> 




More information about the AccessD mailing list