Page 1 of 3 123 LastLast
Results 1 to 10 of 28

what is the "continue" statement for VBA

This is a discussion on what is the "continue" statement for VBA within the Excel Questions forums, part of the Question Forums category; Hi does anyone know what this the continue statement for VBA ? A continue statement is used to end the ...

  1. #1
    New Member
    Join Date
    May 2003
    Posts
    44

    Default what is the "continue" statement for VBA

    Hi

    does anyone know what this the continue statement for VBA? A continue statement is used to end the current loop iteration and return control to the loop statement.

    Thanks

    Regards
    Yee KHoon

  2. #2
    Banned
    Join Date
    Sep 2006
    Location
    Bombay, India
    Posts
    3,274

    Default

    Are you asking a question ? OR you are looking forward for a confirmation of the answer to your question ?

  3. #3
    New Member
    Join Date
    May 2003
    Posts
    44

    Default

    i'm looking for the keyword for continue statement in VBA. In java, there is continue keyword. but i'm not sure whether VBA have or not. i need to use the continue keyword to interate my looping


    Are you asking a question ? OR you are looking forward for a confirmation of the answer to your question ?

  4. #4
    Banned
    Join Date
    Sep 2006
    Location
    Bombay, India
    Posts
    3,274

    Default

    Ok, so your question is proper as you wanna know the syntax that can be replaced for the iteration in your program.

    A friendly suggestion mate...dont complicate yourself comparing Java with VBA...you bet this is way too different in terms of syntax and logic as well...I am a JCP but here I am so a learner in VBA and I do follow a primary principle "never to compare java syntax with VBA" else you wud mess with your Java funda as well !

  5. #5
    New Member
    Join Date
    May 2003
    Posts
    44

    Default

    Hi Stormseed,
    Thanks for your golden advise. I thinking to explore further as i'm not sure whether the VBA have the syntax/keywords. if wud be good if there is such syntax.. right...

    thanks

    Regards
    Yee Khoon

    A friendly suggestion mate...dont complicate yourself comparing Java with VBA...you bet this is way too different in terms of syntax and logic as well...I am a JCP but here I am so a learner in VBA and I do follow a primary principle "never to compare java syntax with VBA" else you wud mess with your Java funda as well !

  6. #6
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    66,268

    Default

    Yee Khon

    What exactly are you trying to do?

    As far as I'm aware there is no equivalent of Continue in VBA.

    But there are probably other methods to achieve what you want.
    If posting code please use code tags.

  7. #7
    New Member
    Join Date
    May 2003
    Posts
    44

    Default

    Hi Norie,
    Again, thanks for replying my post...
    oh yeah... now i thinking to use the Goto syntax to achieve in my loop.

    what i'm exectly want to do is that

    Code:
     
    for i = 0 to ubound(dataArray)
    
        if left(dataArray(i,3), 1) ="z" then continue
        
        
       cells(i,1).value = dataArray(i,1)
    
    next i
    Yee Khon

    What exactly are you trying to do?

    As far as I'm aware there is no equivalent of Continue in VBA.

    But there are probably other methods to achieve what you want.

  8. #8
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling
    Posts
    66,268

    Default

    Yee Khon

    I'm sorry but it still isn't clear what you want to do.

    If you want to exit the for loop based then use Exit For.
    If posting code please use code tags.

  9. #9
    MrExcel MVP
    Join Date
    Apr 2006
    Posts
    15,871

    Default

    Hi Yee

    As you may well know, the use of GoTo is usually considered non structured programming.

    There are 4 usual GoTo variations, the GoTo itsef and its pals Break (Exit in vba), Continue (no equivalent in vba) and Return (also Return in vba). Any of the 4 may break the flow of the program (used inside a loop may even break the logic of the loop) and so, according to the supporters of structured programming, should simply be avoided as much as possible (some will go as far as supporting the removal of this statement from the languages). You can find lots of information about structured programming on the Web and in programming / computer science books.

    So, your:
    Code:
    For/Do/While
        ' code'
        If Condition then Continue
        ' more code'
    End For/Loop
    is equivalent to the also not structured:
    Code:
    For/Do/While
        ' code'
        If Condition then GoTo EndLoop
        ' more code'
    EndLoop:
    End For/Loop
    or, to the classical structured
    Code:
    For/Do/While
        ' code'
        If Not Condition then 
            ' more code'
        End If
    End For/Loop
    Remark: I'm just contributing with information, I'm not saying that you should never use these statements. In some cases they may be useful and in others, for example if you use a switch construct in C/C++, unavoidable.

    Hope this helps
    PGC

  10. #10
    Banned
    Join Date
    Sep 2006
    Location
    Bombay, India
    Posts
    3,274

    Default

    Excellent information and very useful too....PGC !

    thanks a lot for the explanation.

Page 1 of 3 123 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com