?
Solved

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

Posted on 2014-02-20
1
Medium Priority
?
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

770 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