DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557

    Can you put a loop inside an IF statement?

    HIIIIIIII!!!

    I need to run through a chunk of code TWICE if a combo box text is LIKE <whatever>. If the combo box ISN'T LIKE <whatever>, I just need it to run once. Can you do this?

    Code:
    
    If cboNonHourlyDuties.Text Like "*CarSeal*" Then
        csString = "CAR SEALS INSPECTED"
        For indx = 0 To 1
    End If
    
    <Chunk of code>
    
    If cboNonHourlyDuties.Text Like "*CarSeal*" Then
        csString = "CAR SEALS REHUNG"
        Next indx
    End If
    
    L
    Last edited by Laurel; 10-28-2005 at 10:07 AM.
    A balanced diet is a cookie in each hand.

  2. #2
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    The answer is NO! You can NOT do that! SO.....how do I do a loop under certain conditions?
    A balanced diet is a cookie in each hand.

  3. #3
    Join Date
    Dec 2003
    Posts
    2,750
    Not sure if I understand your code but you can use a variable in the For statement in order to specify the number of times it should iterate:

    For indx = 0 to NumIterations - 1

    Next indx
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    for indx = 0 to 1
    <block of the loop>
    if Not cmb... like "..." then exit for
    next

    Marco
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Jun 2004
    Location
    Houston area
    Posts
    557
    OH MARCO! You are such a big strong man!

    You too, Paul!

    L&K
    L
    A balanced diet is a cookie in each hand.

Similar Threads

  1. N6 mouseover inside 'scrolling' DIV
    By Chris Kaminski in forum Web
    Replies: 0
    Last Post: 03-18-2001, 10:54 AM
  2. 'select' statement question again
    By Mango in forum Database
    Replies: 1
    Last Post: 03-07-2001, 11:15 PM
  3. Re: select statement question again
    By MANGO in forum Database
    Replies: 0
    Last Post: 03-06-2001, 09:41 PM
  4. SQL Statement in Excel
    By Hilesh in forum Database
    Replies: 1
    Last Post: 12-26-2000, 11:35 PM
  5. SQL "LIKE" STATEMENT IN FRONT PAGE 2000
    By lUCIA in forum Database
    Replies: 2
    Last Post: 11-22-2000, 12:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links