Home » questions » What is a looping statement? (Visual Basic)?

What is a looping statement? (Visual Basic)?

2006-08-09 23:16:19, Category: Programming & Design
All I need is its importance and what it looks like....

Answers

  1. chetan b

    On 2006-08-09 23:26:46


    A looping statement is one in which you want to execute a statement (or many) as many number of times you want. It is useful when you want to check some constraints with a specific value. Eg: to check if all the textboxes on a form have some data entered in them, you can increment the tab index on the form and check if all textboxes !="" (not equal to 'empty') for i=1 to 10 step +1 text1.seltext="a" next i here, i is the counter which will increment 10 times and a textbox 'text1' will have the letter 'a' appended into it for all those 10 times. take care :)
  2. Anand

    On 2006-08-09 23:23:12


    Looping statement can be used to do repeated execution of certain statements. There are different type of looping. for, while, etc.
  3. Nesquik

    On 2006-08-10 00:04:22


    Looping conditional statements are "Do While" and "For". "Do While" is important when you want loop statements until a condition is met An example "Do While" statement could look like the below: Dim X: X = 1 Do While X < 5 X = (X + 1) Loop Debug.Print X The result of X will be 5 if the loop goes correctly. An For statement is useful when you know how many times you want to loop through some statements. Below is an example: Dim i For i = 1 to 5 Debug.Print "This is loop " & i & "." Next i There is also one more looping conditional statement that has no meaningful purpose and can be interchanged with Do While for same results. The conditional statement is called Do Until which would result oppositely from Do While.