VBScript অ্যারে ফাংশন - VBScript টিউটোরিয়াল 8 এর জন্য একটি চমৎকার গাইড

VBScript টিউটোরিয়াল – বিষয়বস্তুর সারণী

VBScript টিউটোরিয়াল #1: VBScript ভেরিয়েবলের ওভারভিউ 

VBScript টিউটোরিয়াল #2: VBScript শর্তসাপেক্ষ বিবৃতি এবং লুপ

VBScript টিউটোরিয়াল #3: VBScript পদ্ধতি

VBScript টিউটোরিয়াল #4: VBScript এরর হ্যান্ডলিং এবং এক্সিকিউট VBScript

VBScript টিউটোরিয়াল #5: VBScript স্ট্রিং ফাংশন

VBScript টিউটোরিয়াল #6: VBScript তারিখ ফাংশন

VBScript টিউটোরিয়াল #7: VBScript সময় ফাংশন

VBScript টিউটোরিয়াল #8: VBScript অ্যারে ফাংশন

VBScript টিউটোরিয়াল #9: VBScript Math Functions

VBScript টিউটোরিয়াল #10: VBScript Conversion Functions and VBScript Format Functions

VBScript টিউটোরিয়াল #11: VBScript Other Functions 

Through out this “VBScript Array Functions” article, we will explains the different types of frequently used vbscript array functions with examples. The important functions related to array are vbscript join, vbscript array, vbscript filter, vbscript split, etc.

VBScript Tutorial #8: VBScript Array Functions

VBScript Array Functions:

While working with arrays in vbscript, we can use in-build vbscript array functions to perform important array-related operations such as create, manipulate, conversion, etc. This article (VBScript Array Functions) contains all the important built-in VBScript array functions, which are mostly used in programs. 

VBScript Array Functions – Summary:

  • vbscript Array – Defines an array based on given data values.
  • vbscript Filter – Defines a array which is a subset of another one-dimensional string array. The new array is created based on filter criteria.
  • vbscript IsArray – Test a array variable and return a Boolean value based on the result.
  • vbscript Join – Converts an array and returns a string value where all the array elements are separated by a specific delimiter.
  • vbscript Split – Converts a string into a zero-based, one-dimensional array.
  • vbscript LBound – Returns the lower index of an array.
  • vbscript UBound – Returns the upper index of an array that indicates the dimension.

VBScript Array Functions – Details:

All the important vbscript array functions are explained in this section with a proper example.

vbscript Array:

vbscript array function defines an array based on given data values. The array elements are passed the arguments in the vbscript array function.

Syntax: Array(arglist)

প্যারামিটারের বর্ণনা:

যুক্তি তালিকা – These are the mandatory parameters. The list(separated by comma) of arguments are basically the elements of the array.

উদাহরণ:

In the below example, we will create an array of weekdays using vbscript array function and display the first day of the week (0 index) in a message box.

dayArray = Array("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
msgbox "The first day of week: " & dayArray(0)
Output (Message Box): 
The first day of week: Mon
vbscript array functions - vbscript array
vbscript array functions – vbscript array

vbscript Filter:

vbscript filter function defines a zero-based array that contains a subset of a one-dimensional string array. The one-dimensional new array is created based on filter criteria.

Syntax: Filter(string_array,value[,include[,compare]])

প্যারামিটারের বর্ণনা:

string_array – It’s a mandatory parameter which indicates a one-dimensional array of string.

মূল্য – It’s a mandatory parameter which represents the filter criteria, i.e. the string expression to search in the array.

অন্তর্ভুক্ত করা – It’s an optional Boolean parameter. If we provide “true” value as include parameter, it includes the elements which contain the searched criteria. Else, it will exclude the elements which contain the criteria. The default value is true.

তুলনা করা – This is also an optional parameter which specifies the comparison type as binary or textual. If not specified, by default parameter value will be treated as zero. The possible values are – 

· 0 = vbBinaryCompare – Perform a binary checking

· 1 = vbTextCompare – Perform a textual checking

উদাহরণ:

In the below example, we will create an array using vbscript filter function based on the elements of the weekday array, which contains “S” character.

dayArray = Array("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
filterArray = Filter(dayArray, "S")
for each e in filterArray
\tmsgbox e
next
Output (Message Box): 
Sat
Sun

vbscript IsArray:

vbscript isarray function tests and returns a boolean value after checking a specified variable is an array or not. For a valid array, the return value is true else false will be returned.

Syntax: IsArray(variable)

প্যারামিটারের বর্ণনা:

পরিবর্তনশীল – It’s a required parameter which needs to be verified.

উদাহরণ:

In the below example, we will check a variable if it’s an array or not.

dayArray = Array("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
boolFlag = IsArray(dayArray)
msgbox "Return value: " & boolFlag
Output (Message Box): 
Return value: True

vbscript Join:

vbscript join function converts an array into a string expression where all the array elements are separated by a specific delimiter.

বাক্য গঠন: যোগদান(array [, delimiter])

প্যারামিটারের বর্ণনা:

বিন্যাস – It’s a required parameter which represents a one-dimensional array.

সীমানা – It’s an optional parameter which is used to separate each array element after converting into string expression.

উদাহরণ:

In the below example, we will convert the weekday array into a string expression using vbscript join function where all the elements will be separated by a comma.

dayArray = Array("Mon","Tue","Wed","Thu","Fri","Sat","Sun")
dayString = Join(dayArray, ",")
msgbox "Converted week day string: " & dayString
Output (Message Box): 
Converted week day string: Mon,Tue,Wed,Thu,Fri,Sat,Sun
vbscript array functions - vbscript join
vbscript array functions – vbscript join

vbscript Split:

vbscript split function converts a string into a one-dimensional array where array elements are created based on specific delimiters.

বাক্য গঠন: বিভক্ত করা(expression[, delimiter[,count[,compare]]])

প্যারামিটারের বর্ণনা:

অভিব্যক্তি – It’s a required parameter which represents a string expression.

সীমানা – It’s an optional parameter which is used to differentiate each array elements within the string expression. The default value is space.

গণনা – It’s an optional parameter which represents the count of substring/array elements to be returned. The default value -1 specifies that entire string will be returned as single element of the array.

তুলনা করা – This is also an optional parameter which specifies the comparison type as binary or textual. If not specified, by default parameter value will be treated as zero. The possible values are – 

· 0 = vbBinaryCompare – Perform a binary checking

· 1 = vbTextCompare – Perform a textual checking

উদাহরণ:

In the below example, we will convert a string expression, contains all the day name of a week which are separated by semi-column, using vbscript split function. After the conversion, we will display the first and last day of a week.

string_expression = "Mon;Tue;Wed;Thu;Fri;Sat;Sun"
dayArr = Split(string_expression, ";")
msgbox "First day-> " & dayArr(0) & " and Last day-> " & dayArr(6)
Output (Message Box): 
First day-> Mon and Lat day-> Sun
vbscript array functions - vbscript split
vbscript array functions – vbscript split

vbscript LBound:

vbscript lbound function return the lower index, i.e. smallest subscript of an array for the specified dimension. The lbound value for an বিন্যাস সর্বদা 0।

বাক্য গঠন: Lbound(array[,dimension])

প্যারামিটারের বর্ণনা:

বিন্যাস – It’s a required parameter which represents a one-dimensional array.

মাত্রা – It’s an optional parameter which indicates the dimension of the array for which smallest subscript will be returned. The value will be 1 for the first dimension, 2 for the second dimension and so on. The default value is 1. 

উদাহরণ:

In the below example, we will find and display the lower subscript value using vbscript lbound function.

string_expression = "Mon;Tue;Wed;Thu;Fri;Sat;Sun"
dayArr = Split(string_expression, ";")
msgbox "Lbound Value-> " & Lbound(dayArr)
Output (Message Box): 
Lbound Value-> 0

vbscript UBound:

vbscript ubound function return the upper index, i.e. the largest subscript of an array for the specified dimension. The ubound value for an array represent the highest array index i.e. number of element minus one. This function helps to calculate the length of an array.

বাক্য গঠন: উবাউন্ড(array[,dimension])

প্যারামিটারের বর্ণনা:

বিন্যাস – It’s a required parameter which represents a one-dimensional array.

মাত্রা – It’s an optional parameter which indicates the dimension of the array for which smallest subscript will be returned. The value will be 1 for the first dimension, 2 for the second dimension and so on. The default value is 1. 

উদাহরণ:

In the below example, we will find and display the longest subscript value using vbscript ubound function.

string_expression = "Mon;Tue;Wed;Thu;Fri;Sat;Sun"
dayArr = Split(string_expression, ";")
msgbox "Ubound Value-> " & Ubound(dayArr)
Output (Message Box): 
Ubound Value-> 6
vbscript array functions - vbscript ubound
vbscript array functions – vbscript ubound

উপসংহার:

Through this VBScript Array Functions article, we have learned about the frequently used VBScript Array Functions such as, vbscript array, vbscript filter, vbscript join, vbscript split function, etc. In the next vbscript tutorial, we will explain more functions on VBScript functions. Please click to read more on vbscript from এখানে.

মতামত দিন