ArtinSoft's Blogs

Software Migration Experts
Welcome to ArtinSoft's Blogs Sign in | Join | Help
in Search

Mauricio Rojas Blog

Lower Bounds not 0 in VB.NET

The other day a friend asked me. How could he created an array in VB with a lower bound different from 0.

In VB6 you could do something just like this:

Dim b(6 To 12) As Integer 

But in VB.NET it does not work that way. The LowerBound in VB.NET must be always 0. But there is a way to have a lower bound different from 0. It is unclear why this is not very documented but the following code shows how to do it: 

Dim b As Array = Array.CreateInstance(GetType(String), New Integer() {6}, New Integer() {6})

b(6) = 20

b(7) = 1

Comments

No Comments
Powered by Community Server (Non-Commercial Edition), by Telligent Systems