Solved

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

Posted on 2014-02-20
1
289 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get hold of longitude and latitude in iframe string 11 46
vb.net help 4 31
Need to learn more about SecurityProtocolType.Tls12 3 32
bound data table problem 2 11
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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:…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

825 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