Solved

Set the number of elements in an array from input receivied via console.

Posted on 2006-07-20
5
174 Views
Last Modified: 2010-04-23
I need to Dimension an array of integers and set the number of elements in the array based on the response recieved from the console.  Can someone provide an example.  I have tried the example below, but Lenth is read only.

       Dim arValues() As Integer   ' Array to store values
       Dim intElements As Integer   ' The number elements or values to be entered  
       Console.Write("Number of elements in the array (less than 100) : ")
       intElements = Console.ReadLine()
        ' arValues.Length = Int32.Parse(intElements)

I am looking for some guidance or sample code that will help me complete this.  Any information will be greatly appreciated.  Thanks.  DC900

My Environment
    Visual Studio 2005 & VB.NET
0
Comment
Question by:dc900
5 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 150 total points
ID: 17147098
Possibly a ReDim?


Dim arValues() As Integer   ' Array to store values
Dim intElements As Integer   ' The number elements or values to be entered  
Console.Write("Number of elements in the array (less than 100) : ")
intElements = Console.ReadLine()
ReDim arValues(Int32.Parse(intElements))
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 150 total points
ID: 17147222
Just declare the array after you read the console input:

        Dim intElements As Integer = Integer.Parse(Console.ReadLine())
        Dim arValues(i) As String
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

12 Experts available now in Live!

Get 1:1 Help Now