The easiest way create an array is to simply declare it as followsDim strCustomers()
'Another method is to define a variable and then set it as an array afterwardsDim strStaffstrStaff = Array("Alan","Brian","Chris")
'Yet another way is to use the split command to create and populate the arrayDim strProductArraystrProductArray = "Keyboards,Laptops,Monitors"strProductArray = Split(strProductArray, ",")
' To itterate through the contents of an array you can use the For Each loopDim strItemFor Each strItem In strProductArray MsgBox strItemNext
' This will also itterate through the loopDim intCountFor intCount = LBound(strProductArray) To UBound(strProductArray) Msgbox strProductArray(intCount)Next
' This will itterate through the array backwardsFor intCount = UBound(strProductArray) To LBound(strProductArray) Step -1 Msgbox strProductArray(intCount)Next
' To add extra data to an array use Redim PreserveRedim Preserve strProductArray(3)strProductArray(3) = "Mice"' To store the contents of an array into one string, use JoinMsgbox Join(strProductArray, ",")
' To delete the contents of an array, use the Erase commandErase strProductArray
No comments:
Post a Comment