What are the different ways to assign values to an arra…
In VB, you can assign values to arrays using the following methods:
- 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)
- Elements assigned directly to an array.
Dim arr(2) As Integer
arr(0) = 1
arr(1) = 2
arr(2) = 3
- Assign values to an array using looping.
Dim arr(2) As Integer
For i = 0 To 2
arr(i) = i + 1
Next i
- Divide
Dim arr() As String
arr = Split("apple,orange,banana", ",")