Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 28th, 2006, 11:45 PM
Friend of Wrox
 
Join Date: Mar 2005
Location: , , .
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem getting out of infinite loop and incremtin

Hi all. I got this application that once go button clicked it takes single url value and goes trough some process as shown in pic and at the end writes the content of text4 to a text file. Now i want automate this process for range of range of URL i tried to do the following but i get into infinite loop and value of URL does not get incremented and only one url get executed succssefully!! I be happy if some one look at it and let me know how i can fix this problem.Thanks

layout of form without using loop for single url . which works perfectly:

http://i5.photobucket.com/albums/y18...rectOutput.jpg



[VBCODE]
' start from here
'Private Const sURL As String = "http://localhost/player/player.asp?id="
Dim CurrID As Integer


Private Function NextURL(Optional Reset As Boolean = False) As String
    If CurrID = 0 Or Reset Then CurrID = 16411
    If CurrID = 16420 Then Exit Function

 Const sURL As String = "http://localhost/player/player.asp?id="
        'NextURL = sURL & CuurID
        NextURL = sURL & CurrID

        MsgBox "URL:" & NextURL

        CurrID = CurrID + 1

        MsgBox "CurrID" & CurrID

        'Text2.Text = Inet1.OpenURL(CurrURL, icString)
             ' MsgBox "testing"
    'End If
End Function


' once i click the go button this function start with first url and should
keep chaing url by incrementing it untill it reaches end of the range

Private Sub Command3_Click()

Dim CurrURL As String
CurrURL = NextURL
'to reset
CurrURL = NextURL(True)

Text1.Text = CurrURL
MsgBox "CurrentUrl:" & CurrURL
MsgBox "nexturl:" & NextURL

    Select Case Index
    Case 0
        If Text1.Text <> "" Then
            Text2.Text = Inet1.OpenURL(CurrURL, icString)


        End If

    Case 1
        End
    End Select
   'MsgBox "testing"

Command4_Click
Command3_Click ' caling himself again
End Sub

Private Sub Command4_Click()
' It returns a string so just use it like:
'Text3.Text = GetLine2(Text2.Text, "mp3player.swf?playlist=", ".exe")
Text3.Text = "http://localhost/player/" & GetLine2(Text2.Text, "mp3player.swf?playlist=", ".exe")
Command5_Click

End Sub

Private Function GetLine2(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
    Dim lPos As Long, lEnd As String
    lPos = InStr(1, sText, sStart, vbTextCompare)
    If lPos Then
        lEnd = InStr(lPos, sText, sEnd)
        If lEnd Then
            GetLine2 = Mid$(sText, lPos + Len(sStart), lEnd - (lPos + Len(sStart))) & sEnd
        Else
            GetLine2 = Mid$(sText, lPos + Len(sStart))
        End If
    End If
End Function


Private Sub Command5_Click()
Select Case Index
    Case 0:
        If Text3.Text <> "" Then
            Text4.Text = Inet1.OpenURL(Text3.Text, icString)
        End If

    Case 1:
        End
End Select

Command7_Click
End Sub


' this funcion needs to write to a text file
Private Sub Command7_Click()
'Dim Parser As New clsXMLParser
 ' Dim Node As clsXMLNode
  'Dim Child As clsXMLNode
  Dim fn As Long
  'Dim i As Long

 'Dim path As String
  'Dim title As String

  fn = FreeFile
  Open "C:\albums.txt" For Append As #fn
  'Yes. Use Print #fn instead of Write #fn
    'Write #fn, Text4.Text
    Print #fn, Text4.Text
  Close #fn

  MsgBox " file written successfully to the file!"
' after this part i want the url get incremented and it getchecked in Command3_Click

End Sub[/VBCODE]
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
infinite loop smilesmita Pro PHP 1 December 21st, 2007 10:44 AM
problem of infinite loop sarah lee ASP.NET 1.0 and 1.1 Basics 19 December 14th, 2006 09:26 AM
infinite recursion bangbangbogi XSLT 3 May 4th, 2006 05:54 AM
How to Write a Infinite Loop Detection jtdang77 Classic ASP Professional 1 October 15th, 2003 03:44 AM
Infinite Loop Detection jtdang77 Classic ASP Basics 0 October 14th, 2003 05:32 PM



All times are GMT -4. The time now is 12:06 AM.


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