1) Mention what is VBScript?
VB Script stands for Visual Basic Script, and it is a light version of Microsoft Visual Basic. It is a client-side scripting language like JavaScript. VBScript is very similar to that of Visual Basic.
2) Mention the environments where VBScript could be run?
VBScript could be run into 3 environments,
- IIS (Internet Information Server) – Microsoft's web server
- WSH (Windows Script Host)– The native hosting environment of the Windows OS
- IE (Internet Explorer)– The simplest hosting environment we can use to run VBScripts
VB Script provides Technology as,
- Subroutines
- Functions
- String manipulation
- Data/time
- Error Handling, etc.
To name variable in VBScript there are certain rules, you need to use the keyword 'Dim'. For example, Dim salary. Also, you need to remember following things
- Variable name must begin with a letter
- Variable name cannot exceed 255 characters
- Variable name should not contain a period (.)
VBScript allows you to use variables without declaring it known as 'loose binding.' It is not an ideal practice to use it. Because if you misspell the same variable when you use it again then VBScript will not show you of the error.
6) Mention what is variant in VBscript?
Variant in VBscript is a data type. A Variant can contain either string or numeric information. A Variant behaves like a string when you use it in a string context and as a number when you use it in a number context.
7) Mention what is VBScript Procedures?
VBScript procedures are primarily used for code organization and reuse. There are mainly two types of VBScript procedures: Sub procedures and Function procedures.
8) Mention when to use Function procedures and what are its characteristics?
You use Function procedures when you want to execute a series of statements and return a value.
- Function procedures start and end with Function and End Function statements
- A function procedure may or may not take input.
- Function procedures return a value by assigning the value to its name
To call VBScript Functions, you have to follow below rules.
- Mention function name, followed by opening and closing brackets
- Mention all arguments between the brackets that the function requires
To assign a date value to a variable, Date and Time variables should be enclosed within a hash symbol(#)11) Mention how to create a Cookie using VBScript?
The simplest way to create a cookie is to assign a string value to the document.cookie object.
12) Mention how to access Array Data?
Data in an array can be accessed by referring to the name of the array and the element's index number.
13) In HTML file what is an ideal position to include VBScript?
An ideal position to include VBScript in HTML is,
- Inside Head Section
- Inside Body Section
- Inside External File
ByRef and ByVal Parameters in VBScript is used to pass VBScript argument to the procedures by reference or by value
15) Mention what if you do not specify anything when you call a procedure?
If you do not specify anything when you call a procedure, then the argument/arguments are passed by reference by default.
16) Mention what is the use of Option Explicit in VBScript?
The use of Option Explicit statement in VBScript is to initialize all the variable before using them. It helps to avoid typing error in the code.
17) Mention the rules for using Option Explicit statement?
- The Option Explicit statement should be there in a script before any other statements. If not then, a nontrappable error occurs
- In modules where the Option Explicit statement are not declared, any undeclared variables are considered as variants automatically.
- Where Option Explicit is declared, all variables must be declared using the Dim, Public, Private, or ReDim statements.
Difference between VBScript and VBA is that,
VBA | VBScript |
|
|
|
|
|
|
- You can use sub procedures if you want to run a series of statement without returning any value.
- Sub procedures start with "Sub" and ends with "End Sub" statements
- Sub procedures can take arguments but cannot return a value
- Sub procedures may or may not take an input.
Select Case statement is similar to If Then Else but it makes the code more readable.
It works on a single expression and evaluated at the beginning on the Select Case statement.
21) Mention if QTP generates VBScript code as we record actions, can't it possible to directly write using VBScript code when QTP does the same thing too?
No. it is not possible. QTP is the engine that runs through it. The VBScript relies on the QTP UI to perform the actions, such as clicking on a link on a web page.
No comments:
Post a Comment