Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing a Next Statmenent Within a If Statment

Status
Not open for further replies.

Krus1972

Programmer
Mar 18, 2004
145
US
I have the following simple script:

For iCount = 0 To CInt(resultLength)-1

NUMREVIEWS = XML.responseXML.selectSingleNode("dsp/result/domain/domain-listing[" & CInt(iCount)& "]"/num-product-reviews).Text

If NUMREVIEWS = "0" Then
Next iCount
End If
Response.write ("Number of Reviews = " & NUMREVIEWS)
Next



What I am trying to do is to advance the "FOR" statment by 1 (add 1 to iCount) if the NUMREVIEWS = "0". If the NUMREVIEWS is NOT equal to "0" then the NUMREVIEWS will be printed and then afterward +1 will be addedd to iCount.

The problem is ASP will not allow to next statments in the code. Can any one help?

Thnaks,

Jeff
 
[tt]If NUMREVIEWS = "0" Then
[red]'[/red]Next iCount
[blue] 'do nothing
Else[/blue]
Response.write ("Number of Reviews = " & NUMREVIEWS)
End If
[/tt]
 
I'd use a variation of tsuji's code:
Code:
For iCount = 0 To CInt(resultLength)-1 

  NUMREVIEWS = XML.responseXML.selectSingleNode ("dsp/result/domain/domain-listing[" & CInt(iCount) & "]"/num-product-reviews).Text

  If NUMREVIEWS <> "0" Then
    Response.write ("Number of Reviews = " & NUMREVIEWS)
  End If 
Next

Lee
 
Here is a silly way to do it:
Code:
On Error Resume Next
For iCount = 0 To CInt(resultLength)-1 

  NUMREVIEWS = XML.responseXML.selectSingleNode.yada.yada.yada

  blah = 100 / NUMREVIEWS 
  If err.number <> 0 Then
    'we got a divide by zero error!
     err.clear
  Else
    Response.write ("Number of Reviews = " & NUMREVIEWS)
  End If 
Next
 
Another Example:
Code:
For Each node In XML.responseXML.selectNodes("dsp/result/domain/domain-listing[num-product-reviews>0]/num-product-reviews)
   Response.Write node.Text
Next

-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top