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:
[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]
layout of form without using loop for single url . which works perfectly:
[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]