[AccessD] Syntax Problem with Array

Stuart McLachlan stuart at lexacorp.com.pg
Sat Nov 27 18:29:43 CST 2021


Another alternative that achieves the same effect (an immutable "array")  :)

Function LDoms(i As Integer) As Integer
    LDoms = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)(i - 1)
End Function

...
Debug.print LDom(2) ' returns 28


On 27 Nov 2021 at 21:21, Gustav Brock via AccessD wrote:

> Hi Arthur
> 
> Nothing wrong, only is this not VBA syntax.
> 
> You can do something like:
> 
> <code>
>     Const LDoms As String = "31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
>     30, 31" Dim LDom    As Integer
> 
>     ´ Pick the 5th element.
>     LDom = CInt(Split(LDoms, ",")(4))
> 
>     Debug.Print LDom
> </code>
> 
> Fra: Arthur Fuller<mailto:fuller.artful at gmail.com>
> Sendt: 27. november 2021 21:34
> Til: Access Developers discussion and problem
> solving<mailto:accessd at databaseadvisors.com> Emne: [AccessD] Syntax
> Problem with Array
> 
> 1. I'm trying to declare a Constant array. This is not working:
> 
> Const LDoms() as Integer = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31,
> 30, 31} I  get the same bad result if I use parentheses instead of
> curly braces.
> 
> What am I doing wrong?
> 
> 
> --
> 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