Tuesday, June 28, 2016

Learn VB Script Part 7

Using Loop Statements

Do.. Loop Statement

Do...Loop: 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]


Examples 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   then
                                    
                                                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

   MsgBox Counter

Loop


Example 4
'Exit Do Until loop

Do
    
   Counter=Counter + 1

     If  Counter = 6 Then

        Exit Do

     End If

   MsgBox Counter
   
Loop Until counter >11




1 comment:

  1. At Indian Cyber Army, applicants wishing to build up profession in Ethical hacking and Cyber security will motivate opportunity to take in the abilities for Describe Footprinting, Scanning, and Enumeration, Hacking Web servers and Web applications, DoS, SQL infusion, Buffer flood assaults, Cryptography, Wireless hacking, Linux Hacking, Countermeasures, Ethical hacking training on continuous tasks alongside moral hacking arrangement preparing.

    ReplyDelete