I need to define a two dimensional array and assign values. I was wondering if there is an easier way in vb.net to do this other then how I have it below. some of my other arrays have over 700 elements in them.

Dim L1(8, 2) As Double

L1(0, 0) = 0
L1(1, 0) = 6.2170397
L1(2, 0) = 3.055655
L1(3, 0) = 6.10455
L1(4, 0) = 2.83532
L1(5, 0) = 5.8268
L1(6, 0) = 2.5185
L1(7, 0) = 5.48
L1(0, 1) = 3.052
L1(1, 1) = 2.149
L1(2, 1) = 6.12
L1(3, 1) = 0.0
L1(4, 1) = 5.62
L1(5, 1) = 4.57
L1(6, 1) = 3.04
L1(7, 1) = 5.09

Recommended Answers

All 4 Replies

If the elements are stored in a database or Excel workbook, you can just pass it in with a loop.

Where are you getting your data from? (If you can disclose that information)

They are currently in a text file, I could import them into a excel spread sheet.

I was thinking there might be a way to define them like in c++

Double L1[8, 2]  = { 0, 
                 6.2170397,
                 3.055655,
                 6.10455,
                 2.83532,
                 5.8268,
                 2.5185,
                 5.48},
                {3.052,
                 2.149,
                 6.12,
                 0.0,
                 5.62, 
                 4.57,
                 3.04,
                 5.09}

but vb.net does not like that.

The easiest way I know of would be to loop through the file and add the values.
If they were comma delimited and in order, you could just loop until you hit end of file.

Ulpoad data from text file and create database for the same.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.