Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

help: add row to 2D jagged array

Posted on 2003-03-04
9
Medium Priority
?
744 Views
Last Modified: 2008-02-01
I am writing in VB.net, using VS.net .  I've used the following syntax to declare a 2D jagged array with no rows:

Dim students As student()() = New student()() {}

Is this correct? Now when a new student must be added to the array, I must "add a row".  How do I do this?  I am pretty sure I must start with "Redim Preserve"
0
Comment
Question by:dbyrne03
  • 6
  • 3
9 Comments
 
LVL 2

Expert Comment

by:Jacamar
ID: 8068766


Redim Preserve student(1 to blah, 1 to blah)
0
 

Author Comment

by:dbyrne03
ID: 8068938
what would be the value of 'blah' if I were to add one row to the array?
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8069051
ok, use a value like say

inRows

that will keep track of your rows.  Your statement would be

inRows = inRows + 1
redim preserve student(1 to inRows, 1 to inColumns)

sorry about the unclearity, I don't know why I did that.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:dbyrne03
ID: 8069072
I can't get to a compiler until tomorrow but I think this'll do it.
0
 

Author Comment

by:dbyrne03
ID: 8082945
when doing the above, the "to" in the parentheses has a jagged blue underline.  Hovering the cursor over this line reads "Comma, ')' or a valid expression continuation is expected".  I've been poking arounf and VS.net seems to only accept integer values within either set of parentheses.
0
 

Author Comment

by:dbyrne03
ID: 8082961
also, it appears as though the above would be used to redifine a rectangular array, as you have one set of parentheses.  Wouldn't I need two pairs, since this is a jagged array?
0
 

Author Comment

by:dbyrne03
ID: 8083106
also, it appears as though the above would be used to redifine a rectangular array, as you have one set of parentheses.  Wouldn't I need two pairs, since this is a jagged array?
0
 

Author Comment

by:dbyrne03
ID: 8083120
actually, here's what worked:

' create jagged two-dimensional array
Dim myarray As String()()

'adds a row to the jagged array
Dim rowtotal As Integer
rowtotal = myarray.GetUpperBound(0) + 1
ReDim Preserve myarray(rowtotal)
myarray(rowtotal) = New String() {""}
0
 
LVL 2

Accepted Solution

by:
Jacamar earned 130 total points
ID: 8083471
Cool.  I'm glad you solved.
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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

578 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