adsense


Sunday, 8 November 2015

VB SCRIPT SPLIT FUNCTION PAGE 60

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button




VB SCRIPT SPLIT FUNCTION





Split Function 



A Split Function returns an array that contains a 
specific number of values split based on a Delimiter. 
Syntax
Split(expression[,delimiter[,count[,compare]]]) 

• expression, a Required parameter. The String 
Expression that can contain strings with delimiters. 

 

• delimiter, an Optional Parameter. The Parameter, 
which is used to convert into arrays based on a delimiter. 

 

• count, an Optional Parameter. The number of substrings to 
be returned, and if specified as -1, then all the substrings are returned. 

 

• compare, an Optional Parameter. This parameter specifies which comparison method to be used. 

o 0 = vbBinaryCompare - Performs a binary comparison 

o 1 = vbTextCompare - Performs a textual comparison
 

 
Example 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
' Splitting based on delimiter comma '$' 
a=Split("Red $ Blue $ Yellow","$") 
b=ubound(a) 
For i=0 to b 
   document.write("The value of array in " & i & " is :"  & a(i)& "<br />") 
Next 
 
</script> 
</body> 
</html> 
When the above code is saved as .HTML and executed 
in Internet Explorer, it produces the following result: 
The value of array in 0 is :Red  
The value of array in 1 is : Blue  
The value of array in 2 is : Yellow 
Join Function 
A Function, which returns a String that contains 
a specified number of substrings in an array. 
This is an exact opposite function of Split Method. 
Syntax 
Join(List[,delimiter])  

• List, a Required parameter. An Array that 
contains the substrings that are to be joined. 



• delimiter, an Optional Parameter. The Character, 
which used as a delimiter while returning the string. 
The Default delimiter is Space. 

 
Example 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
' Join using spaces 
a = array("Red","Blue","Yellow") 
b = join(a) 
document.write("The value of b " & " is :"  & b & "<br />") 
 
' Join using $ 
b = join(a,"$") 
document.write("The Join result after using delimiter is : " & b & "<br />") 
 
</script> 
</body> 
</html> 
When the above code is saved as .html and executed 
in Internet Explorer, it produces the following result: 
The value of b is :Red Blue Yellow 
The Join result after using delimiter is : Red$Blue$Yellow 
Filter Function 
A Filter Function, which returns a zero-based array 
that contains a subset of a string array based on a specific filter criteria. 
Syntax 
Filter(inputstrings,value[,include[,compare]])  

• inputstrings, a Required parameter. This parameter 
corresponds to the array of strings to be searched. 



• value, a Required Parameter. This parameter corresponds 
to the string to search for against the inputstrings parameter. 

 

• include, an Optional Parameter. This is a Boolean value, 
which indicates whether or not to return the substrings that 
include or exclude. 

 

• compare, an Optional Parameter. This Parameter describes 
what string comparison method to be used. 

o 0 = vbBinaryCompare - Performs a binary comparison 

o 1 = vbTextCompare - Performs a textual comparison

Example 
<!DOCTYPE html> 
<html> 
<body> 
<script language="vbscript" type="text/vbscript"> 
 
a= array("Red","Blue","Yellow") 
b = Filter(a,"B") 
c = Filter(a,"e") 
d = Filter(a,"Y") 
 
For each x in b 
  Document.write("The Filter result 1: " & x & "<br />") 
Next 
 
For each y in c 
  Document.write("The Filter result 2: " & y & "<br />") 
Next 
 
For each z in d 
  Document.write("The Filter result 3: " & z & "<br />") 
Next 
 
</script> 
</body> 
</html> 
When the above code is saved as .HTML and executed in 
Internet Explorer, it produces the following result: 
The Filter result 1: Blue 
The Filter result 2: Red 
The Filter result 2: Blue 
The Filter result 2: Yellow 
The Filter result 3: Yellow 


 




No comments: