filmov
tv
Excel VBA-Dynamic array introduction.
Показать описание
Excel VBA-Dynamic array introduction
Option Explicit
Option Base 1
Sub CreateDynamicArray()
Dim myarr() As Variant
ReDim myarr(2) As Variant
myarr(1) = "John"
myarr(2) = "142"
ReDim Preserve myarr(4)
myarr(3) = "Sinha"
myarr(4) = Now
Erase myarr()
End Sub
Sub DynamicArrayExample()
Dim arr() As Variant
Dim i As Integer
ReDim arr(1) As Variant
arr(1) = 125
ReDim Preserve arr(3) As Variant
arr(2) = "Akash"
arr(3) = Date
For i = LBound(arr()) To UBound(arr)
MsgBox arr(i)
Next i
End Sub
Option Explicit
Option Base 1
Sub CreateDynamicArray()
Dim myarr() As Variant
ReDim myarr(2) As Variant
myarr(1) = "John"
myarr(2) = "142"
ReDim Preserve myarr(4)
myarr(3) = "Sinha"
myarr(4) = Now
Erase myarr()
End Sub
Sub DynamicArrayExample()
Dim arr() As Variant
Dim i As Integer
ReDim arr(1) As Variant
arr(1) = 125
ReDim Preserve arr(3) As Variant
arr(2) = "Akash"
arr(3) = Date
For i = LBound(arr()) To UBound(arr)
MsgBox arr(i)
Next i
End Sub