Public Const a = (1, 10, 5)Originally Posted by neverland
Const arrays are not supported.
Alternatives are individual consts with similar names,
Or store a string as a constant and the split it into a global arrayCode:Const A1=1 Const A2=10 Const A3=5
Another alternative could be to use a class. Here you could use an array and make the values readonly.Code:Const AVALUES = "1:10:5" Public A(2) as Integer Public Sub MyMacro() A = Split(AVALUES, ":") Debug.Print A(0) Debug.Print A(1) Debug.Print A(2) End Sub
You do nothing wrong, my bad
The result of the split function needs to be a variant and not a specified integer array.
Try this mod.
Code:Const AVALUES = "1:10:5" Public A(2) As Integer Public Sub MyMacro() Dim vntTemp As Variant Dim intIndex As Integer vntTemp = Split(AVALUES, ":") For intIndex = 0 To 2 A(intIndex) = vntTemp(intIndex) Next Debug.Print A(0) Debug.Print A(1) Debug.Print A(2) End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)