• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

What am I doing wrong with this array?

GoingUp

Lifer
Trying to initialize a 3 row x 4 column array in VB.Net

Private storage As String(,) = New String(2, 3) {}

storage(0,0) = "Tax Benefits"
storage(1,0) = "Political Stability"
storage(2,0) = "Relocation Costs"

when I try to put in the strings into the array, it tells me that a declaration is expected....

what am I missing here... its gotta be obvious
 
Private storage As String(,) = New String(2, 3) {}

--> wouldn't this intialize a 2x3 array?

storage(2,0) = "Relocation Costs" --> try taking this line out and in the first statement i dont think you need the braces {}
(not too sure in vb.net tho)
 
cs371 eh? Lab2?

Try using Dim storage As String(,) = New String(2, 3) {} instead of private.

EDIT: actually, that doesn't matter. 😱

EDIT2: actually, that might matter.
 
I got it this time.

You need to put:

storage(0,0) = "Tax Benefits"
storage(1,0) = "Political Stability"
storage(2,0) = "Relocation Costs"

in a Sub method.

You can only delcaire variables ( like the Private storage As String(,) = New String(2, 3) {} and probably give them some initial values) outside a sub method. This makes sence because when would the computer know to run:

storage(0,0) = "Tax Benefits"
storage(1,0) = "Political Stability"
storage(2,0) = "Relocation Costs"

when no method is called to do it.
 
Back
Top