Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 07:58:40 AM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  array question
Pages: 1   Go Down
Print
Author Topic: array question  (Read 389 times)
0 Members and 2 Guests are viewing this topic.
hdscarbro
Active Member

Offline Offline

Posts: 14


View Profile
« 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.
Logged
Ya-Nvr-No
Active Member

Offline Offline

Posts: 268


Scuptris 3D


View Profile
« Reply #1 on: December 10, 2010, 04:14:49 PM »

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
« Last Edit: December 10, 2010, 04:19:31 PM by Ya-Nvr-No » Logged
hdscarbro
Active Member

Offline Offline

Posts: 14


View Profile
« Reply #2 on: December 10, 2010, 09:44:20 PM »

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).


Logged
Ya-Nvr-No
Active Member

Offline Offline

Posts: 268


Scuptris 3D


View Profile
« Reply #3 on: December 11, 2010, 09:55:52 PM »

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

Logged
hdscarbro
Active Member

Offline Offline

Posts: 14


View Profile
« Reply #4 on: December 12, 2010, 11:05:59 AM »

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.



Logged
Ya-Nvr-No
Active Member

Offline Offline

Posts: 268


Scuptris 3D


View Profile
« Reply #5 on: December 12, 2010, 05:57:36 PM »

Maybe the powers to be, will take notice and solve the issue, thanks for the lesson.
Logged
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!