• Saves Valuable Time
  • Trusted Accuracy for 12 Years
  • 15-Day Money-Back Guarantee

VB Equivalent to Java Arrays

Unsized Array

Java VB
int[] myArray = null; Dim myArray() As Integer = Nothing

Sized Array

Java VB
int[] myArray = new int[2]; Dim myArray(1) As Integer

Access Array Element

Java VB
x = myArray[0]; x = myArray(0)

Jagged Array

Java VB
int[][] myArray = new int[2][]; Dim myArray(1)() As Integer

Rectangular Array

Java VB
int[][] myArray = new int[2][3]; Dim myArray()() As Integer = RectangularArrays.ReturnRectangularIntegerArray(2, 3)

'----------------------------------------------------------------------------------------
' Copyright © 2007 - 2017 Tangible Software Solutions Inc.
' This module can be used by anyone provided that the copyright notice remains intact.
'
' This module includes methods to convert Java rectangular arrays (jagged arrays
' with inner arrays of the same length).
'----------------------------------------------------------------------------------------
Friend Module RectangularArrays
    Friend Function ReturnRectangularIntegerArray(ByVal size1 As Integer, ByVal size2 As Integer) As Integer()()
        Dim newArray As Integer()() = New Integer(size1 - 1)() {}
        For array1 As Integer = 0 To size1 - 1
            newArray(array1) = New Integer(size2 - 1) {}
        Next array1

        Return newArray
    End Function
End Module


Use Java to VB Converter to convert from Java to VB.     


Copyright © 1997 – 2017 Tangible Software Solutions Inc.