Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
|
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 8th, 2005, 01:55 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default Moving through a Do Loop

Okay, this should be simple but I can't find out how to do it.

I have a Do Loop. There is a counter and the loop runs until the counter reaches a certain number.

One of the things the loop does is look up some records in a database on each pass, but if there are no records, I want the loop to cycle prematurely. I can't get VBScript to allow me to do this.

This is sort of what I want to do but the syntax doesn't work:

'=====
Do Until i = 20
'open recordset
   If objRecordset.RecordCount = 0 Then
    i = i + 1
    Loop
   Else
    ...
   End If
i = i + 1
Loop
'=====

It's that Loop in the If Then End If statement that is not working. I get a Loop without Do error and the script won't run.

I am sure one of you has a very elegant solution. I am looking forward to smacking myself in the forehead for not thinking of it.

Thanks,



mmcdonal
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
Reply With Quote
  #2 (permalink)  
Old April 8th, 2005, 02:10 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

SMACK!

Okay, I'm glad I figured this out before anyone read this.

I just removed the Loop from the first condition and it works.

Egads, what a newbtard I am.



mmcdonal
Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving viewport schoolBoy Javascript How-To 7 March 7th, 2007 05:03 PM
Moving a file pakman Excel VBA 2 January 14th, 2005 10:49 AM
Need help moving my database seanmayhew BOOK: ASP.NET Website Programming Problem-Design-Solution 1 December 30th, 2004 05:00 PM
moving a column p_gauri7 Crystal Reports 6 December 20th, 2004 03:27 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.