Results 1 to 14 of 14

Thread: For Next - Resolved I reckon

  1. #1

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    For Next - Resolved I reckon

    Isn't there a way to set 2 ranges in a For Next loop?

    Say

    For i = 0 To 10 AND 30 to 45

    I thought it was possible, but I am likely wrong...
    Last edited by Spajeoly; Oct 21st, 2009 at 05:49 PM.

  2. #2
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: For Next

    Quote Originally Posted by Spajeoly View Post
    Isn't there a way to set 2 ranges in a For Next loop?

    Say

    For i = 0 To 10 AND 30 to 45

    I thought it was possible, but I am likely wrong...
    you can do
    For i = 0 To 10
    for x = 30 to 45
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  3. #3

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: For Next

    One loop, not 2. I think I am just high or something

    So basically have I go from 0 To 10 then 30 to 45
    Last edited by Spajeoly; Oct 21st, 2009 at 04:07 PM.

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: For Next

    If it just that example then you can do something like this.... just a workaround...

    vb Code:
    1. Private Sub Sample()
    2.     Dim i As Long
    3.     '~~> For i = 0 To 10 AND 30 to 45
    4.     For i = 0 To 45
    5.         If i < 11 Or i > 29 Then
    6.            '~~> Your code
    7.         End If
    8.     Next i
    9. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: For Next

    Another workable solution:
    Code:
    For i = 0 to 45
       If i = 11 Then i = 30
       ' ...
    Next i

  6. #6

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: For Next

    Yeah, I reckon I can settle for that.

    I don't know where I thought I had seen this but I was obviously just being retroactively mistaken.

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: For Next

    AFAIK there is no way to keep them in the same line as you want it....

    So Is your query resolved?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: For Next

    Fine

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: For Next - Resolved I reckon

    Then do remember to mark this thread resolved Check the link in my signature on how to mark the thread resolved
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: For Next

    Quote Originally Posted by Spajeoly View Post
    I don't know where I thought I had seen this...
    Perhaps in Select Case syntax:
    Code:
    Select Case X
    Case 0 To 11, 30 To 45
    ...
    End Select

  11. #11
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: For Next - Resolved I reckon

    Correct, LogoPhobic. The For ... Next coupled with the Select Case ... End Select will work.
    Doctor Ed

  12. #12

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: For Next - Resolved I reckon

    Quote Originally Posted by koolsid View Post
    Then do remember to mark this thread resolved Check the link in my signature on how to mark the thread resolved
    I am well aware of the process of editing a thread, I have 2 years on you here after all.

    I had marked it resolved before your reply as well, so please do remember to check before commanding.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: For Next - Resolved I reckon

    Marking a thread as resolved does not need to involve the effort of editing - and while you have added the word Resolved to the title, it is far from the manner we all expect it, so it is easy to miss (I had to check twice if it was there for koolsid's reply!).

  14. #14
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: For Next - Resolved I reckon

    Quote Originally Posted by Spajeoly View Post
    I am well aware of the process of editing a thread, I have 2 years on you here after all.

    I had marked it resolved before your reply as well, so please do remember to check before commanding.
    @Spajeoly: I know you have been in the forum much before me but what made you think that I was commanding ? It was just a simple polite request

    The idea behind marking a thread is to let other members know that your problem is sorted so that they don't waste their time
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

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