code conversion help needed
Hi can someone help me convert my old vb6 coding over to vb.net thanks in advance
Code:
Dim HTML, start, a, B, As Long
Dim Gend As String
Private Sub Command1_Click()
Call Getpages
End Sub
Sub Getpages()
Gend = "http://localhost/interests.php?view=ALL"
Form1.Caption = "Encore ~ Titles Collecting..."
Do
HTML = Inet1.OpenURL(Gend)
Loop Until Inet1.StillExecuting = False
Debug.Print HTML
Open "C:\dvd_titles.txt" For Append As #1
start = 1
Do Until InStr(start, HTML, "/interests.php?dvd=") = 0
a = InStr(start, HTML, "/interests.php?dvd=") + 19
B = InStr(a, HTML, """>") - a
start = a + B
Print #1, Mid(HTML, a, B)
Loop
Close #1
End Sub
Re: code conversion help needed
anyone know how to convert the Do statement i have?
Re: code conversion help needed
Quote:
Originally Posted by devGOD
anyone know how to convert the Do statement i have?
Under "TOOLS" there is a tool to Upgrade you VB6 code... It's pretty nice.. I use it at times...
Re: code conversion help needed
it doesn't work on that coding =/
Re: code conversion help needed
Try This
VB Code:
Private Const SearchString As String = "/interests.php?dvd="
Private Const EndChars As String = "&"">" ' stop when we find a '"', '>' or '&'
Private Function GetPages(ByVal Url As String) As ArrayList
Dim wc As New System.Net.WebClient
Dim sr As New IO.StreamReader(wc.OpenRead(Url))
Dim strRawHtml As String = sr.ReadToEnd ' Get The entire file into one string
sr.Close()
wc = Nothing
'Process
Dim arUrls As New ArrayList
'Format: <a href="/interests.php?dvd={value}">{Caption}</a>
Dim iIndex As Integer = 0
Do Until iIndex = strRawHtml.Length - 1 '
iIndex = strRawHtml.IndexOf(SearchString, iIndex)
If iIndex = -1 Then
'There is no more instances of SearchString
Exit Do
End If
Dim iEndIndex As Integer = -1
For Each c As Char In EndChars.ToCharArray
iEndIndex = strRawHtml.IndexOf(c, iIndex)
If Not iEndIndex = -1 Then
Exit For
End If
Next
If iEndIndex = -1 Then
Exit Do ' we failed, due to invaild url formatting
End If
'If were are still here then we found one :D
arUrls.Add(strRawHtml.Substring(iIndex, iEndIndex - iIndex))
Loop
Return arUrls ' should now contain list of dvd titles???
End Function
VB Code:
'test
Dim Urls as ArrayList = GetPages("http://localhost/interests.php?view=ALL")
For Each s as String in Urls
Msgbox(s)
Next