Results 1 to 4 of 4

Thread: Do Loops

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    karachi
    Posts
    90
    Hello,
    Could any one tell me why and when
    we use do loops with example .
    Bye

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Do loops are used to repeat some event until some action happens which is going to stop the loop.This loop will loop until or while that action has happened.It is mosy often used when we don't know how many times we want something to happen but it depends of the user or smth. else.
    Code:
    Do While Form1.Top < 5000
    Form1.Top = Form1.Top + 20
    Loop
    This will move the form down while its top position is smaller than 5000.
    Code:
    Do Until Form1.Top > 5000
    Form1.Top = Form1.Top + 20
    Loop
    This does the same thing just instead of while we use until.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Guest
    Code:
    Dim f as integer
    f = freefile
    Dim InputStr as string
    
    open "C:\Windows\desktop\mydata.txt" for input as #f
    do while not EOF(f)
    line input #f,inputstr
    'do some processing with each line of the file
    loop
    close #f

  4. #4
    Guest
    If you know how many times you want to loop, it's better to use a For loop as it is slightly faster.
    Code:
    For I = 0 To MyNumber 'i.e 1000
        Print "Hello"
    Next I

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width