VBScript Basics, Part 44 | Creating Arrays (Arrays)

Опубликовано: 14 Октябрь 2024
на канале: SimplyCoded
15,476
129

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 »    • VBScript Basics, Part 42 | Mid - Spli...  
Adding to Arrays »    • VBScript Basics, Part 45 | Adding to ...  

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

___