|
-
Dec 30th, 2004, 03:53 AM
#1
Thread Starter
Hyperactive Member
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
-
Dec 30th, 2004, 04:52 PM
#2
Thread Starter
Hyperactive Member
Re: code conversion help needed
anyone know how to convert the Do statement i have?
-
Dec 30th, 2004, 09:55 PM
#3
Frenzied Member
Re: code conversion help needed
 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...
10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".
-
Dec 30th, 2004, 11:43 PM
#4
Thread Starter
Hyperactive Member
Re: code conversion help needed
it doesn't work on that coding =/
-
Dec 31st, 2004, 06:12 AM
#5
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
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|