Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: hdscarbro on December 10, 2010, 01:35:26 PM
-
Is there are way of expressing the assignment "d = c(1)" that works in VB?
"d = a" works and MsgBox(d(0)) returns 11.
a = Array(11, 12, 13)
b = Array(14, 15, 16)
c = Array(a, b)
MsgBox(IsArray(c)) 'True
d = c(1) 'Error on line:5 - Type mismatch
Thanks in advance.
-
a = Array(11, 12, 13)
b = Array(20, 21, 22)
c = Array(a(1), b(1))
MsgBox(c(0))
MsgBox(c(1))
For x = 0 To 2
For y = 0 To 2
d = a(x)
e = b(y)
MsgBox(d*e)
Next y
Next x
-
Thanks for the reply, but it isn't what I want to do. I want to create an array of references to arrays.
Using my example, here's what I want to do.
a = Array(11, 12, 13)
b = Array(14, 15, 16)
ar = a 'this works in Mach VB, ar is a reference to the array a
MsgBox(ar(1)) 'this works in Mach VB, prints 12
c = Array(a, b) 'this compiles in Mach, VB, presumably c contains references to the arrays a and b
d = c(1) ' this doesn't work, if it did, d would contain a reference to the array b
MsgBox(d(1)) 'and it would print 15
The intriguing thing about all of this is IsArray(c(1)) returns true, but I can't figure out a syntax for getting at the elements of the array at c(1).
-
gettype=VarType(c)
MsgBox(gettype)
'comes back a 12, Sorry I dont know what a 12 is
'0 thru 8 is all I find.
Guess it cant be done using this version of VB
-
Arrays are type 12
a = Array(1,2)
b = Array(3,4)
c = Array(a,b)
MsgBox(VarType(a)) 'returns 12
MsgBox(VarType(a(0))) 'returns 2
MsgBox(VarType(c)) 'returns 12
MsgBox(VarType(c(0))) 'returns 8204
At
http://www.chennaiiq.com/developers/reference/visual_basic/functions/vartype.asp
I discovered 8204 is an array of variants
According to information found other places using the search "vartype 8204", to It should be possible to do either:
MsgBox(c(0)(0) )
or
ar=c(0)
MsgBox(ar(0))
to get the the first element of the array a.
Guess this is a bug in the version of Cypress Enable that Mach uses.
-
Maybe the powers to be, will take notice and solve the issue, thanks for the lesson.