Automation testing QTP with VB Script functions Interview questions


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

Do...Loop Statement?

Do...Loop statement repeats a block of statements while a condition is True or until a condition becomes True.

Syntax:
 Do [{While | Until} condition]
   [statements]
   [Exit Do]
   [statements]
Loop
OR
Do
   [statements]
   [Exit Do]
   [statements]
Loop [{While | Until} condition]

Arguments:
condition: Numeric or string expression that is True or False. If condition is Null, condition is treated as False.
statements: One or more statements that are repeated while or until condition is True.

Example-1: 

'Do...Loop
Counter = 1
    Do While Counter < 4
Total =Inputbox("Please enter the total marks in numbers") 
   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
    Counter = Counter + 1
Loop

Example-2: 

Counter = 1
           Do 
 Total =Inputbox("Please enter the total marks in numbers")             
        If   Total < 50 Then               
       MsgBox  "Fail"               
         ElseIf  Total >=50 and Total <=60   then
     Msgbox "Second Class"                            
    ElseIf  Total >60 and Total <80   the                         Msgbox "First Class"   
        ElseIf  Total >=80  then    
     Msgbox "Distinction"
       Else             
     Msgbox "Invalid Marks"                         
       End If
        Counter = Counter + 1
        Loop until Counter > 4

Example-3: 

   'Exit Do While loop
Do While Counter < 10
Counter=counter + 1
If  counter = 6 Then
    Exit Do
End If
Print Counter
    Loop

Example-4: 

'Exit Do Until loop
Do   
Counter=Counter + 1
If  Counter = 6 Then
    Exit Do
End If
Print Counter 
Loop Until counter >11


 




Next 5 interview question(s)

1
For...Next Statement?
2
For Each...Next Statement?
3
If...Then...Else Statement?
4
Select Case statement?
5
While...Wend statement?

Comments