This bug is known and logged, waiting to be fixed.
This is also a known bug.
To work around at this moment, set in the application.myapp the option MySubMain to false, regenerate (right click on the file in the tree and click on Update Application.designer.vb) and provide your own Sub Main in the project.
Thanks Theo
Version 10.0.0.2525 initialising an array using upperbound of array is out by 1 as below :
Dim array1() As Integer = {32, 27, 64, 18, 95}
Console.WriteLine($“array1 length = {array1.Length}”)
Console.WriteLine($“Upperbound of array1 = {array1.GetUpperBound(0)}”)
// allocate 2nd array based on length of array1
Dim array2(array1.GetUpperBound(0)) As Integer
Console.WriteLine($“array2 length = {array2.Length}”)
Console.WriteLine($“Upperbound of array2 = {array2.GetUpperBound(0)}”)
Personally, I prefer the c#, oxygene method of specifying the array length rather than upper bound.
Also, the redim statememt fails with error No such static member
The VB way of declaring arrays has always been by specifying the upper bound, not the amount of elements.
So,
Dim a(10) As String 'will create an array with 11 elements; 0 - 10
Will create an array with the elements a(0) to a(10)
The code:
Dim array1() As Integer = {32, 27, 64, 18, 95}
Console.WriteLine($“array1 length = {array1.Length}”)
Console.WriteLine($“Upperbound of array1 = {array1.GetUpperBound(0)}”)
Will print 5 and 4, because the length of the array is 5 elements (0-4) and the upperbound is 4
It is not a question of what you prefer, but a question of how the language works.
Just the VB way of doing things - see: Arrays - Visual Basic | Microsoft Learn
Edit: Just saw that Redim will be in the next version.