Results 1 to 4 of 4

Thread: problem getting out of infinite loop and incremting values

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow problem getting out of infinite loop and incremting values

    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:





    VB Code:
    1. ' start from here
    2. 'Private Const sURL As String = "http://localhost/player/player.asp?id="
    3. Dim CurrID As Integer
    4.  
    5.  
    6. Private Function NextURL(Optional Reset As Boolean = False) As String
    7.     If CurrID = 0 Or Reset Then CurrID = 16411
    8.     If CurrID = 16420 Then Exit Function
    9.    
    10.  Const sURL As String = "http://localhost/player/player.asp?id="
    11.         'NextURL = sURL & CuurID
    12.         NextURL = sURL & CurrID
    13.        
    14.         MsgBox "URL:" & NextURL
    15.  
    16.         CurrID = CurrID + 1
    17.        
    18.         MsgBox "CurrID" & CurrID
    19.        
    20.         'Text2.Text = Inet1.OpenURL(CurrURL, icString)
    21.              ' MsgBox "testing"
    22.     'End If
    23. End Function
    24.  
    25.  
    26. [B]' once i click the go button this function start with first url and should
    27. keep chaing url by incrementing it untill it reaches end of the range[/B]
    28. Private Sub Command3_Click()
    29.  
    30. Dim CurrURL As String
    31. CurrURL = NextURL
    32. 'to reset
    33. CurrURL = NextURL(True)
    34.  
    35. Text1.Text = CurrURL
    36. MsgBox "CurrentUrl:" & CurrURL
    37. MsgBox "nexturl:" & NextURL
    38.  
    39.     Select Case Index
    40.     Case 0
    41.         If Text1.Text <> "" Then
    42.             [B]Text2.Text = Inet1.OpenURL(CurrURL, icString)[/B]
    43.              
    44.            
    45.         End If
    46.    
    47.     Case 1
    48.         End
    49.     End Select
    50.    'MsgBox "testing"
    51.    
    52. Command4_Click
    53. Command3_Click ' caling himself again
    54. End Sub
    55.  
    56. Private Sub Command4_Click()
    57. ' It returns a string so just use it like:
    58. 'Text3.Text = GetLine2(Text2.Text, "mp3player.swf?playlist=", ".exe")
    59. Text3.Text = "http://localhost/player/" & GetLine2(Text2.Text, "mp3player.swf?playlist=", ".exe")
    60. Command5_Click
    61.  
    62. End Sub
    63.  
    64. Private Function GetLine2(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String) As String
    65.     Dim lPos As Long, lEnd As String
    66.     lPos = InStr(1, sText, sStart, vbTextCompare)
    67.     If lPos Then
    68.         lEnd = InStr(lPos, sText, sEnd)
    69.         If lEnd Then
    70.             GetLine2 = Mid$(sText, lPos + Len(sStart), lEnd - (lPos + Len(sStart))) & sEnd
    71.         Else
    72.             GetLine2 = Mid$(sText, lPos + Len(sStart))
    73.         End If
    74.     End If
    75. End Function
    76.  
    77.  
    78. Private Sub Command5_Click()
    79. Select Case Index
    80.     Case 0:
    81.         If Text3.Text <> "" Then
    82.             Text4.Text = Inet1.OpenURL(Text3.Text, icString)
    83.         End If
    84.    
    85.     Case 1:
    86.         End
    87. End Select
    88.  
    89. Command7_Click
    90. End Sub
    91.  
    92.  
    93. ' this funcion needs to write to a text file
    94. Private Sub Command7_Click()
    95. 'Dim Parser As New clsXMLParser
    96.  ' Dim Node As clsXMLNode
    97.   'Dim Child As clsXMLNode
    98.   Dim fn As Long
    99.   'Dim i As Long
    100.  
    101.  'Dim path As String
    102.   'Dim title As String
    103.  
    104.   fn = FreeFile
    105.   Open "C:\albums.txt" For Append As #fn
    106.   'Yes. Use Print #fn instead of Write #fn
    107.     'Write #fn, Text4.Text
    108.     Print #fn, Text4.Text
    109.   Close #fn
    110.  
    111.   [B]MsgBox " file written successfully to the file!"[/B]
    112. ' after this part i want the url get incremented and it getchecked in Command3_Click
    113.  
    114. End Sub
    Last edited by tony007; Apr 28th, 2006 at 07:33 PM.

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