every one!
kisi k pas for lop, while lop, do lop, nested lop ki examples hain jin ko krne se loops theak tarah se samjh a jain plz output k sath shair kr dian thanks
every one!
kisi k pas for lop, while lop, do lop, nested lop ki examples hain jin ko krne se loops theak tarah se samjh a jain plz output k sath shair kr dian thanks
Do { While | Until } condition
[ statements ]
[ Exit Do ]
[ statements ]
Loop
-or-
Do
[ statements ]
[ Exit Do ]
[ statements ]
Loop { While | Until } condition
Use a Do...Loop structure when you want to repeat a set of statements an indefinite number of times, until a condition is satisfied. If you want to repeat the statements a set number of times, the For...Next Statement is usually a better choice.
The Do...Loop structure gives you more flexibility than the While...End While Statement (Visual Basic) because it allows you to choose whether to end the loop when condition stops being True or when it first becomes True. It also allows you to test condition at either the beginning or the end of the loop.
Rules
Nature of Condition. The condition usually results from a comparison of two values, but it can be any expression that evaluates to a Boolean Data Type (Visual Basic) value (True or False). This includes values of other data types, such as numeric types, that have been converted to Boolean.
Testing the Condition. You can test condition only once, at either the beginning or the end of the loop. You can use either While or Until to specify condition, but not both.
Number of Iterations. If you test condition at the beginning of the loop (in the Do statement), the loop might never run even once. If you test at the end of the loop (in the Loop statement), the loop always runs at least once.
Nesting Loops. You can nest Do loops by placing one loop within another. You can also nest different kinds of control structures within one another. For more information, see Nested Control Structures.
Transferring Out of the Loop. The Exit Statement (Visual Basic) transfers control immediately to the statement following the Loop statement. You might want to exit a loop if you detect a condition that makes it unnecessary or impossible to continue iterating, such as an erroneous value or a termination request. You can place any number of Exit Do statements anywhere in the Do loop. Exit Do is often used after evaluating some condition, for example in an If...Then...Else structure.
Endless Loops
One use of Exit Do is to test for a condition that could cause an endless loop, which is a loop that could run an extremely large or even infinite number of times. If you detect such a condition, you can use Exit Do to escape the loop. Otherwise, the loop continues running.
In the following example, number is assigned a value that could cause the loop to run more than 2 ^ 31 times. The If statement checks for this condition and exits if it exists, preventing endless looping.
Google per ya MSDN per aapko Loops aor nested lopps ki hazaron examples mil jaa'in gi.
Agar aap koi kisi particular cheez ke baray mein ja'na chahtay hain to wo likhain, shukriya.
Sub exitDoExample()
Dim counter As Integer = 0
Dim number As Integer = 8
Do Until number = 10
If number <= 0 Then Exit Do
number -= 1
counter += 1
Loop
MsgBox("The loop ran " & counter & " times.")
End Sub
While condition
[ statements ]
[ Exit While ]
[ statements ]
End While
Dim counter As Integer = 0
While counter < 20
counter += 1
' Insert code to use current value of counter.
End While
MsgBox("While loop ran " & CStr(counter) & " times")
Use a While...End While structure when you want to repeat a set of statements an indefinite number of times, as long as a condition remains True. If you want more flexibility with where you test the condition or what result you test it for, you might prefer the Do...Loop Statement (Visual Basic). If you want to repeat the statements a set number of times, the For...Next Statement (Visual Basic) is usually a better choice.
If condition is True, all of the statements run until the End While statement is encountered. Control then returns to the While statement and condition is again checked. If condition is still True, the process is repeated. If it is False, control passes to the statement following the End While statement.
thankss
[FONT="Jameel Noori Nastaleeq"][CENTER][COLOR="Blue"][SIZE="5"][B]Coming Soon...:)[/B][/SIZE][/COLOR][/CENTER][/FONT]
Bookmarks