Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

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 …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

783 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