Automation testing QTP with VB Script functions Interview questions


Total available count: 68
Subject - Software Testing
Subsubject - Automation testing QTP with VB Script functions

If...Then...Else Statement?

If...Then...Else statement conditionally executes a group of statements, depending on the value of an expression.

Syntax:
If condition Then statements [Else elsestatements ] 
OR
If condition Then
   [statements]
[ElseIf condition-n Then
   [elseifstatements]] . . .
[Else
   [elsestatements]]
End If 

Arguments:
condition: One or more of the following two types of expressions. A numeric or string expression that evaluates to True or False. If condition is Null, condition is treated as False. 
An expression of the form Type of objectname Is object type. The object name is any object reference and object typeis any valid object type. The expression is True if object name is of the object type specified by object type; otherwise it is False.
statements: One or more statements separated by colons; executed if condition is True.
condition-n: Same as condition.
elseifstatements: One or more statements executed if the associated condition-n is True.
elsestatements: One or more statements executed if no previous condition or condition-n expression is True.

Example-1: 

'If...Then...Else
Total = Inputbox("Please enter the total marks in number ")
            If   Total >= 50 Then
              MsgBox  "Pass"         
            Else          
                        Msgbox "Fail"   
            End If

Example-2: 

'If....ElseIf
Total = Inputbox("Please enter the total marks in number")
            If   Total < 50 Then         
                        MsgBox  "Fail"            
            ElseIf  Total >=50 and Total <=60   then
                        Msgbox "Second Class"
            ElseIf  Total >60 and Total <80   then          
                        Msgbox "First Class"
            ElseIf  Total >=80  then
                        Msgbox "Distinction"
            Else
                Msgbox "Invalid Marks"          
            End If

 




Next 5 interview question(s)

1
Select Case statement?
2
While...Wend statement?
3
With statement?
4
FSO(File system object)?
5
Object/Collection Description?

Comments