Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,900 questions

51,831 answers

573 users

How to use Array.CreateInstance() method to initializes a new instance of the Array class in VB.NET

1 Answer

0 votes
Module Module1

    Sub Main()

        Dim intArray As Array = Array.CreateInstance(GetType(Int32), 5)
        Dim i As Integer

        For i = intArray.GetLowerBound(0) To intArray.GetUpperBound(0)
            intArray.SetValue(i + 10, i)
        Next

        PrintArray(intArray)

    End Sub

    Public Sub PrintArray(arr As Array)
        Dim i As Integer
        For i = arr.GetLowerBound(0) To arr.GetUpperBound(0)
            Console.WriteLine("arr({0}) = {1}", i, arr.GetValue(i))
        Next i
    End Sub

End Module

' run:
' 
' arr(0) = 10
' arr(1) = 11
' arr(2) = 12
' arr(3) = 13
' arr(4) = 14

 



answered Apr 15, 2016 by avibootz
...