Results 1 to 5 of 5

Thread: code conversion help needed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377

    Question 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

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377

    Re: code conversion help needed

    anyone know how to convert the Do statement i have?

  3. #3
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    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...
    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".

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    377

    Re: code conversion help needed

    it doesn't work on that coding =/

  5. #5
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: code conversion help needed

    Try This

    VB Code:
    1. Private Const SearchString As String = "/interests.php?dvd="
    2.     Private Const EndChars As String = "&"">" ' stop when we find a '"', '>' or '&'
    3.  
    4.     Private Function GetPages(ByVal Url As String) As ArrayList
    5.         Dim wc As New System.Net.WebClient
    6.  
    7.         Dim sr As New IO.StreamReader(wc.OpenRead(Url))
    8.  
    9.         Dim strRawHtml As String = sr.ReadToEnd ' Get The entire file into one string
    10.  
    11.         sr.Close()
    12.  
    13.         wc = Nothing
    14.  
    15.         'Process
    16.  
    17.         Dim arUrls As New ArrayList
    18.  
    19.         'Format: <a href="/interests.php?dvd={value}">{Caption}</a>
    20.  
    21.         Dim iIndex As Integer = 0
    22.  
    23.         Do Until iIndex = strRawHtml.Length - 1 '
    24.             iIndex = strRawHtml.IndexOf(SearchString, iIndex)
    25.             If iIndex = -1 Then
    26.                 'There is no more instances of SearchString
    27.                 Exit Do
    28.             End If
    29.  
    30.             Dim iEndIndex As Integer = -1
    31.  
    32.             For Each c As Char In EndChars.ToCharArray
    33.                 iEndIndex = strRawHtml.IndexOf(c, iIndex)
    34.                 If Not iEndIndex = -1 Then
    35.                     Exit For
    36.                 End If
    37.             Next
    38.  
    39.             If iEndIndex = -1 Then
    40.                 Exit Do ' we failed, due to invaild url formatting
    41.             End If
    42.  
    43.             'If were are still here then we found one :D
    44.             arUrls.Add(strRawHtml.Substring(iIndex, iEndIndex - iIndex))
    45.  
    46.         Loop
    47.  
    48.         Return arUrls ' should now contain list of dvd titles???
    49.  
    50.     End Function

    VB Code:
    1. 'test
    2.  
    3. Dim Urls as ArrayList = GetPages("http://localhost/interests.php?view=ALL")
    4.  
    5. For Each s as String in Urls
    6.     Msgbox(s)
    7. 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
  •  



Click Here to Expand Forum to Full Width