VBScript Multiple choices


Total available count: 25
Subject - Scripting Languages
Subsubject - VBScript

What is the use of the InStr() function in VBScript?


 

 

 

 



C


Solution:-

The InStr Function
The InStr function returns the first occurrence of one string within another string. Generally, the search happens from left to right.

The InStr Function Syntax is as follows:

InStr([start,]string1,string2[,compare])

Description

  • Specifies the starting position for the search. The search begins at the first position from left to right. The start is an Optional Parameter. 
  • String to be searched and String1 is a Required Parameter. 
  • String against which String1 is searched. String2 is a Required Parameter. 
  • Specifies the String Comparison to be used. Compare is an Optional Parameter.  It can take the following mentioned values −

                  0 = vbBinaryCompare - Performs Binary Comparison(Default)
                  1 = vbTextCompare - Performs Text ComparisonThe InStr Function Example is as below:

<!DOCTYPE html>
<html>
 <body>
   <script language = "vbscript" type = "text/vbscript">
    var = "SlightBook Website"
    document.write("Line 1 : " & InStr(1,var,"i") & "<br />")
    document.write("Line 2 : " & InStr(7,var,"0") & "<br />")
    document.write("Line 3 : " & InStr(1,var,"f",1) & "<br />")
    document.write("Line 4 : " & InStr(1,var,"t",0) & "<br />")
    document.write("Line 5 : " & InStr(1,var,"l") & "<br />")
    document.write("Line 6 : " & InStr(7,var,"i") & "<br />")
    document.write("Line 7 : " & InStr(var,"We"))
   </script>
 </body>
</html>

The above script will produce the following result when you save it as .html and execute it in the browser:

Line 1: 3
Line 2: 0
Line 3: 8
Line 4: 6
Line 5: 2
Line 6: 16
Line 7: 12




Next 5 multiple choice(s)

1

What is the use of the Chr() function in VBScript?

2

What is the use of the Asc() function in VBScript?

3

What is the use of the Len() function in VBScript?

4

What is the use of Mid() function in VBScript?

5

What is the use of Spaces() function in VBScript?

Comments