Solved

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

Posted on 2006-07-20
5
180 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
[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
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

627 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