Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays in VB .NET 2012 1

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
Again, as a former VFP programmer, I'm used to have multi-dimensional arrays to hold different data types in different columns, e.g.
Code:
DECLARE ARRAY laValues[3, 5]
FOR I=1 TO 5
   laValues[I, 1] = I
   laValues[I, 2] = ".\WrkDir\Wrk" + STR(I)
   laValues[I, 3] = .F.
NEXT I
that is 1st column has Int, 2nd - String, 3rd - Boolean.

Is two-dimensional array in VB .NET able to hold different data types in different columns too?
If so - please tell me how to.
TIA!

Regards,

Ilya
 
Yes, it can./ Simply declare in VB without a datatype, e.g:

Code:
[blue]    Dim laValues(5, 3)
    For I As Integer = 1 To 5
        laValues(I, 1) = I
        laValues(I, 2) = ".\WrkDir\Wrk" + Str(I)
        laValues(I, 3) = False
    Next I[/blue]

Note that VB arrays are 0-based, whilst FFP arrays are 1-based, so you may need to refactor your code slightly
 
Thank you StrongM!
I thought that with .NET MS made VB strong-typed...
As for 0-based, I recall there was some setting/option in pre-.NET VBs where one could make it 0- or 1-based.
I tried to find it in the VB .NET VS 2012 - and could not.
Is it still there?

Regards,

Ilya
 
>there was some setting/option

Yes, in classic VB there was [tt]Option Base[/tt], which allowed you to modify this. It does not exist in VB.NET, which is why I made the point.
 
StrongM said:
... in classic VB there was Option Base ... It does not exist in VB.NET
Alas!
Thank you, colleague!

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top