VBA, inline array

Looking for creating an inline array in Visual Basic for Applications

Something like this would be cool:

Dim a() as Integer
set a = {1,2,3} 

In Java, this will be equivalent functionality:

int a[] = {1,2,3};

In addition, bonus points, if you can tell me how to subsequently find its length (without the need for a hard code, since all the examples that my Google uncovered),

(please don’t tell me on Google. I usually don’t use vb and I find that every result for a vb question on Google is a very creepy answer. ex, hard coding values)

+3
source share
1 answer
Dim a() As Variant
Dim Length As Integer

a = Array(1,2,3)

Length = UBound(a,1) - LBound(a,1) + 1
+11
source

Source: https://habr.com/ru/post/1744406/


All Articles