Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

How will you trim the spaces on the left of a string using VBScript?

Answer»

Using Ltrim function, which returns a string after removing the spaces on the left side of the specified string.

52.

How will you convert a string to upper case string using VBScript?

Answer»

Using Ucase function, which returns the upper case of the specified string.

53.

How will you convert a string to lower case string using VBScript?

Answer»

Using Lcase function, which returns the lower case of the specified string.

54.

How will you get the last occurrence of one string within another string using VBScript?

Answer»

Using InStrRev function, which returns the first occurrence of one string within another string. The search happens from right to left.

55.

How will you get the first occurrence of one string within another string using VBScript?

Answer»

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

56.

How will you get the exponent of the given number in VBScript?

Answer»

Using Exp function, which returns the value of e raised to the specified number.

Example −

Dim num : num = -645.998651document.write("Exp Result of num is : " & Exp(num))& "<br/>" '2.79479883633128E-281
57.

How will you get the absolute value of the given number in VBScript?

Answer»

Using Abs function, which returns the absolute value of the given number.

Example −

Dim num : num = -645.998651document.write("Abs Result of num is : " & Abs(num))& "<br/>" '645.998651
58.

How will you get the square root of the given number in VBScript?

Answer»

Using Sqr function, which returns the square root of the given number.

Example −

Dim num : num = -210document.write("Sqr Result of num is : " & Sqr(num))& "<br/>" '14.4913767461894
59.

How will you get a random number between 0 and 1 in VBScript?

Answer»

Using Rnd function,which returns a random number between 0 and 1.

Example −

Dim num : num = -645.998651document.write("Rnd Result of num is : " & Rnd(num))& "<br/>" '0.5130115
60.

How will you get the hexadecimal value of the given number in VBScript?

Answer»

Using Hex function, which returns the hexadecimal value of the given number.

Example −

Dim num : num = -645.998651document.write("Hex Result of num is : " & Hex(num))& "<br/>" 'FFFFFD7A
61.

How will you get the octal value of the given number in VBScript?

Answer»

Using Oct function, which returns the octal value of the given number.

Example −

Dim num : num = -645.998651document.write("Oct Result of num is : " & Oct(num))& "<br/>" '37777776572
62.

How will you get the natural logarithm of the given number in VBScript?

Answer»

Using Log function, which returns the natural logarithm of the given number.

Example −

Dim num : num = 210document.write("Log Result of num2 is : " & Log(num2))& "<br/>" '5.34710753071747
63.

How will you get the integer part of a number in VBScript?

Answer»

Using Int function, which returns the integer part of the given number.

Example −

Dim num : num = -645.998651document.write("int Result of num is : " & int(num))& "<br/>"  '-646
64.

How will you format a number in percetage format in VBScript?

Answer»

Using FormatPercent function, which would return an expression formatted as a percent.

Example −

Dim num : num = -645.998651document.write(FormatPercent(num, 2))& "<br/>"    '-64,599.86%
65.

How will you format a number upto 3 decimal places in VBScript?

Answer»

Using FormatNumber function, which would return an expression formatted as a number.

Example −

Dim num : num = -645.998651document.write(FormatNumber(num, 3))& "<br/>"     '-645.999
66.

How will you convert a given number to Hexadecimal in VBScript?

Answer»

Using Hex function, which converts a given number of any variant subtype to Hexadecimal.

Example −

x = 123y = 123.882document.write("y value after converting to Hex -" & Hex(y) & "<br />") 
67.

How will you convert a given number to Single in VBScript?

Answer»

Using CSng function, which converts a given number of any variant subtype to Single.

Example −

x = 123y = 123.882document.write("x value after converting to Single -" & CSng(x) & "<br />")
68.

How will you convert a given number to Long in VBScript?

Answer»

Using CLng function, which converts a given number of any variant subtype to Long.

Example −

x = 123y = 123.882document.write("x value after converting to Long -" & CLng(x) & "<br />")
69.

How will you convert a given number to Integer in VBScript?

Answer»

Using CInt function, which converts a given number of any variant subtype to Integer.

Example −

x = 123y = 123.882document.write("y value after converting to Int - " & CInt(y) & "<br />")
70.

How will you convert a given number to double in VBScript?

Answer»

Using CDbl function, which converts a given number of any variant subtype to double.

Example −

x = 123y = 123.882document.write("x value after converting to double - " & CDbl(x) & "<br />")
71.

How to delete a Cookie using VBScript?

Answer»

Sometimes you will want to delete a cookie so that subsequent attempts to read the cookie return nothing. To do this, you just need to set the expiration date to a time in the past.

72.

How to read a Cookie using VBScript?

Answer»

Reading a cookie is just as simple as writing one, because the value of the document.cookie object is the cookie. So you can use this string whenever you want to access the cookie.

The document.cookie string will keep a list of name=value pairs separated by semicolons, where name is the name of a cookie and value is its string value.

You can use strings' split() function to break the string into key and values.

73.

How to create a Cookie using VBScript

Answer»

The simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this −

Syntax −

document.cookie = "key1 = value1; key2 = value2; expires = date";

Here expires attribute is optional. If you provide this attribute with a valid date or time then cookie will expire at the given date or time and after that cookies' value will not be accessible.

74.

Can you access Cookie using VBScript?

Answer»

VBScript can also manipulate cookies using the cookie property of the Document object. JavaScript can read, create, modify, and delete the cookie or cookies that apply to the current web page.

75.

What is the output of A & B in VBScript if A = "VB" and B = "Script"?

Answer»

& operator concatenates two values. So A & B will give VBScript.

76.

What is the output of A & B in VBScript if A = 5 and B = 10?

Answer»

& operator concatenates two values. So A + B will give 510.

77.

What is the output of A + B in VBScript if A = "VB" and B = "Script"?

Answer»

+ operator concatenates two Values if values are string. So A + B will give VBScript.

78.

What is the output of A + B in VBScript if A = 5 and B = 10?

Answer»

+ operator adds two Values as Variable Values are Numeric. So A + B will give 15.

79.

Which opearator can be used to do an XOR operation in VBScript?

Answer»

XOR Called Logical Exclusion operator. It is used to do an XOR operation.

Example −

A. Dim a : a = 5Dim b : b = 10Dim cc = b XOR aDocument.write ("XOR Check is " &c)
80.

Which opearator can be used to check if two numbers are equal or not in VBScript?

Answer»

<> operator is used to check if two numbers are equal or not.

Example −

Dim a : a = 5Dim b : b = 10Dim cc = b <> aDocument.write ("Equality Check is " &c)
81.

Which opearator can be used to get the exponent of a number in VBScript?

Answer»

^ opeator is used to get the exponent of two numbers.

Example −

Dim a : a = 5Dim b : b = 10Dim cc = b ^ aDocument.write ("Exponentiation Result is " &c)
82.

Which opearator can be used to get the modulus of two numbers in VBScript?

Answer»

MOD opeator is used to get the modulus of two numbers.

Example −

Dim a : a = 5Dim b : b = 10Dim cc = b MOD aDocument.write ("Modulus Result is " &c)
83.

How many types of operators VBScript supports?

Answer»

VBScript language supports following types of operators −

  • Arithmetic Operators

  • Comparison Operators

  • Logical (or Relational) Operators

  • Concatenation Operators

84.

What is the scopt of constant declared using Private?

Answer»

Private Constants are available within the procedure or Class.

85.

What is the scope of a constant declared using Public?

Answer»

The Public constants are available for all the scripts and procedures.

86.

How will you declare a constant in VBScript?

Answer»

Constants are declared using "const" keyword.

87.

What is the scope of a variable declared using Private?

Answer»

Variables that are declared as "Private" have scope only within that script in which they are declared. When declaring a variable of type "Private", Dim keyword is replaced by "Private".

88.

What is the scope of a variable declared using Public?

Answer»

Variables declared using "Public" Keyword are available to all the procedures across all the associated scripts. When declaring a variable of type "public", Dim keyword is replaced by "Public".

89.

What is the scope of a variable declared using Dim?

Answer»

Variables declared using "Dim" keyword at a Procedure level are available only within the same procedure. Variables declared using "Dim" Keyword at script level are available to all the procedures within the same script.

90.

What are the valid scopes of a variable in VBScript?

Answer»

Following are the scopes of variable in VBScript −

  • Dim

  • Public

  • Private

91.

How to assign a date value to a variable?

Answer»

Date and Time variables should be enclosed within hash symbol(#).

92.

How to assign a string value to a variable?

Answer»

The String values should be enclosed within doublequotes(").

93.

How to assign a numeric value to a variable?

Answer»

The numeric values should be assigned without double quotes.

94.

Do you need to specify the type of variable during declaration?

Answer»

No! Since there is only ONE fundamental data type, all the declared variables are variant by default. Hence, a user NEED NOT mention the type of data during declaration.

95.

How do you declare a variable in VBScript?

Answer»

Variables are declared using "dim" keyword.

96.

What are the variable naming conventions in VBScript?

Answer»

Variable is a named memory location used to hold a value that can be changed during the script execution. VBScript has only ONE fundamental data type, Variant.

Rules for Declaring Variables −

  • Variable Name must begin with an alphabet.

  • Variable names cannot exceed 255 characters.

  • Variables Should NOT contain a period(.)

  • Variable Names should be unique in the declared context.

97.

Is VBScript case sensitive?

Answer»

No! VBScript is a case-insensitive language. This means that language keywords, variables, function names and any other identifiers need NOT be typed with a consistent capitalization of letters.

So identifiers int_counter, INT_Counter and INT_COUNTER have the same meaning within VBScript.

98.

What are the disadvantages of VBScript?

Answer»

Following are the disadvantages of VBScript −

  • VBscript is used only by IE Browsers. Other browsers such as Chrome, Firefox DONOT Support VBScript. Hence, JavaScript is preferred over VBScript.

  • VBScript has a Limited command line support.

  • Since there is no development environment available by default, debugging is difficult.

99.

What are the advantages of VBScript?

Answer»

Following are the advantages of VBScript −

  • VBScript is a lightweight scripting language, which has a lightning fast interpreter.

  • VBScript, for the most part, is case insensitive. It has a very simple syntax, easy to learn and to implement.

  • Unlike C++ or Java, VBScript is an object-based scripting language and NOT an Object-Oriented Programming language.

  • It uses Component Object Model (COM) in order to access the elements of the environment in which it is executing.

  • Successful execution of VBScript can happen only if it is executed in Host Environment such as Internet Explorer (IE), Internet Information Services (IIS) and Windows Scripting Host (WSH).

100.

What is VBScript?

Answer»

Microsoft VBScript (Visual Basic Script) is a general-purpose, lightweight and active scripting language developed by Microsoft that is modelled on Visual Basic. Nowadays, VBScript is the primary scripting language for Quick Test Professional (QTP), which is a test automation tool.