?
Solved

Whats the best way to create a multidimensional array

Posted on 2006-05-02
2
Medium Priority
?
252 Views
Last Modified: 2010-04-23
I want a 2D array that can store  2 numbers and a string eg: (2,'National',1.5) (256, 'Local',1.55)
Whats the best way of going about this...arraylists?
0
Comment
Question by:Milkus1
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 16592960
You could write a Class to encapsulate your data and then store instances of that class in an ArrayList:

    Public Class Data
        Public myInt As Integer
        Public myStr As String
        Public myDbl As Double
    End Class

    Private myData As New ArrayList

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim d As Data

        d = New Data
        d.myInt = 2
        d.myStr = "National"
        d.myDbl = 1.5
        myData.Add(d)

        d = New Data
        d.myInt = 256
        d.myStr = "Local"
        d.myDbl = 1.55
        myData.Add(d)

        Debug.WriteLine(myData(0).myStr)
        Debug.WriteLine(myData(1).myInt)
    End Sub
0
 

Author Comment

by:Milkus1
ID: 16593255
Yep works a treat, thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

807 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