?
Solved

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

Posted on 2014-02-20
1
Medium Priority
?
311 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 2000 total points
ID: 39875796
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

862 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