[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

loading an array

Posted on 2006-06-16
15
Medium Priority
?
209 Views
Last Modified: 2011-09-20
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
0
Comment
Question by:Autofreak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 2
  • +1
15 Comments
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16923989
Hi,

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

However, myArray must be of Variant type.



---
Harish
0
 

Author Comment

by:Autofreak
ID: 16924024
What if it's two_dimensional?
Serge
0
 
LVL 37

Accepted Solution

by:
Harisha M G earned 800 total points
ID: 16924025
Autofreak, somewhat better if you want to take care of the type also...

    Dim iArray() As Integer
    myarray = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    For i = LBound(myarray) To UBound(myarray)
        ReDim Preserve iArray(LBound(myarray) To i)
        iArray(i) = myarray(i)
    Next

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 37

Expert Comment

by:Harisha M G
ID: 16924032
   myarray = Array(Array(1, 2, 3, 4),Array(5, 6, 7, 8),Array(9, 10, 11, 12), _
                    Array(13, 14, 15, 16))
0
 

Author Comment

by:Autofreak
ID: 16924209
Cool
        How do I retrieve myArray(0,1) in one line?? It does't onderstand this syntax.
Thanks
Serge

0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16924218
You told the answer yourself !!

myArray(0,1)

!!
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16924228
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.
0
 

Author Comment

by:Autofreak
ID: 16924311
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
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16924404
Are you using VB6 or Vb.Net?
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16924409
what exactly are you storing ?
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16924426
Idle_Mind, if it were VB.NET, then he could have assigned it directly, as in C#
I think it is VB 6.


0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16924428
Right...with slight differences in syntax.

I just wanted to be sure.  =)
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 16924446
:)
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16924651
if you needed it:
string = CStr(varient)
0
 

Author Comment

by:Autofreak
ID: 16995465
Sorry Guys, So distracted I was, eXcellent tips,

Cheers
Serge
                 
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question