VBScript Basics, Part 44 | Creating Arrays (Arrays)


VBScripting (.vbs) Basic tutorial on how to use Arrays. That inclueds their functions such as LBound, UBound, Join, IsArray, Array, Filter, and even a special bit of code that lets you search through your array.

Split Command » http://youtu.be/WQ5qE9NqPmk
Adding to Arrays » http://youtu.be/gKOHXKwqOnc

Code Example:
___

Option Explicit
Dim Weekdays

Weekdays = Array(“Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”)

If IsInArray(“Monday”, Weekdays) Then
MsgBox “Yes, that is in your array.”
MsgBox Join(Weekdays, vbLf),0, “Here is all the values:”
Else
MsgBox “No, that is not in your array.”
MsgBox Join(Weekdays, vbLf),0, “Here is all the values:”
End If

Function IsInArray(strValue, ArrCheck)
‘Author: Justin Doles – www.DigitalDeviation.com Dim bFlag :
bFlag = False
If IsArray(ArrCheck) AND Not IsNull(strValue) Then
Dim i For i = 0 to UBound(ArrCheck)
If ArrCheck(i) = strValue Then
bFlag = True
Exit For
End If
Next
End If
IsInArray = bFlag
End Function

___



Leave a Comment