?
Solved

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

Posted on 2006-07-20
5
Medium Priority
?
181 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 600 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 600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

718 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