Results 1 to 6 of 6

Thread: [RESOLVED] For ..Next Trouble

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    Resolved [RESOLVED] For ..Next Trouble

    Dim i as Integer
    For i = 0 To position
    'Do something here
    Next i

    However if postion is 0 Then the do someting is still execute How can i make sure the if position = 0 Then No For Next Loop.

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    269

    Re: For ..Next Trouble

    just add an if:
    For i = 0 To position
    if position <> 0 then
    'Do something here
    Next i

  3. #3
    Hyperactive Member
    Join Date
    Aug 2004
    Location
    Itasca, IL USA
    Posts
    266

    Re: For ..Next Trouble

    You could change the for to a do loop... Do while i < position. Or maybe add the following to your for statement...
    VB Code:
    1. If position = 0 then
    2.      exit for
    3. end if
    Last edited by Chrissy; Apr 11th, 2006 at 03:31 PM. Reason: formatting

  4. #4
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    269

    Re: For ..Next Trouble

    sorry. better add it outside:
    If position <> 0 then
    For i = 0 To position
    'Do something here
    Next i
    End if

  5. #5

  6. #6
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    Re: For ..Next Trouble

    if you dont want to do anything with 0 you can just start the loop at 1

    VB Code:
    1. For i = 1 to position
    Chris

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