Solved

Is there a VB.NET equivalent to READ / DATA in  basic?

Posted on 2014-02-20
1
285 Views
Last Modified: 2014-02-21
I want to fill an array   Values(20,20) with 400 distinct values.  In the old days I could do this with 20 lines of code like this:
DATA 3,12,24,25,67,234 (and so forth)

And then simply "read" the data lines into my array.  
How can I fill my array with data without using an external file or database, but just using lines of code without having to do it manually (i.e. Values(1,1) = 3  Values(1,2) = 12  Values(1,3) = 24)  Manually would be so time consuming.  Is there a nice equivalent to READ/DATA commands in old basic that can quickly fill an array in .NET basic?
0
Comment
Question by:arthurh88
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
There is not direct equivalent, but you can initialize the values of an array when you declare it.

This is the syntax for a single dimension array:

            Dim x() As Integer = {3, 12, 24, 25, 67, 234}

And here is the syntax for a two dimensions array:

            Dim y(,) As Integer = {{3, 12, 24}, {25, 67, 234}}

Note that arrays are always initialized at an index of 0, and there is not way such as Option Base to change that, so the last one would give you

y(0,0)=3
y(0,1)=12
y(0,2)=24
y(1,0)=25
...
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now