Link to home
Start Free TrialLog in
Avatar of Autofreak
Autofreak

asked on

loading an array

Hi Guys,
            Is it possible to load an array in VB the way itcam be done in C#,

int[] myArray = {1,4,6,7,8,9,0,7};

Thanks
Serge
Avatar of Harisha M G
Harisha M G
Flag of India image

Hi,

myArray = Array(1,4,6,7,8,9,0,7)

However, myArray must be of Variant type.



---
Harish
Avatar of Autofreak
Autofreak

ASKER

What if it's two_dimensional?
Serge
ASKER CERTIFIED SOLUTION
Avatar of Harisha M G
Harisha M G
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
   myarray = Array(Array(1, 2, 3, 4),Array(5, 6, 7, 8),Array(9, 10, 11, 12), _
                    Array(13, 14, 15, 16))
Cool
        How do I retrieve myArray(0,1) in one line?? It does't onderstand this syntax.
Thanks
Serge

You told the answer yourself !!

myArray(0,1)

!!
Oh.. sorry.. you should use

myArray(0)(1)

to get 2 (1st row, 2nd column)

Usually 0,1 is used. However, in this case, we are using a variant to act as an array. So, we should use this syntax.
Damn it,
          the functions that recieve the values from the array compalin on argument type mismatch ,
is there a function to convert a variant into a string?

Serge
Are you using VB6 or Vb.Net?
what exactly are you storing ?
Idle_Mind, if it were VB.NET, then he could have assigned it directly, as in C#
I think it is VB 6.


Right...with slight differences in syntax.

I just wanted to be sure.  =)
if you needed it:
string = CStr(varient)
Sorry Guys, So distracted I was, eXcellent tips,

Cheers
Serge