What are the different ways to assign values to an arra…

In VB, you can assign values to arrays using the following methods:

  1. Array is a type of data structure that stores elements of the same data type in a contiguous memory location.
Dim arr(2) As Integer
arr = Array(1, 2, 3)
  1. Elements assigned directly to an array.
Dim arr(2) As Integer
arr(0) = 1
arr(1) = 2
arr(2) = 3
  1. Assign values to an array using looping.
Dim arr(2) As Integer
For i = 0 To 2
    arr(i) = i + 1
Next i
  1. Divide
Dim arr() As String
arr = Split("apple,orange,banana", ",")
bannerAds