0

Dear to all,
How to make Regex match code for vb6 to extract domain names but only with related links like this.For example if i write the word "visual basic" then my program show me related links about the word "visual basic" in a list box. such as http://www.vbforbegginers.com
http://www.vb.nethardturorials.info
http://www.vb.netgodcity.us
http://www.vb.netfunnytutorials.com
but my code does not show me any result.

Dim  dsource  As String
Dim result
dsource = "http://www.google.lt/search?num=100&q=" & Text2.Text
Set regweb = New RegExp            ' Create a regular expression.
regweb.Pattern = "http://\b\w+\s\\(net|com|us|org|ru|lt|co.uk|tr|info(ftp|telnet)\*$"
regweb.IgnoreCase = True         ' Set case insensitivity.
regweb.Global = True           ' Set global applicability.
        result = Inet1.OpenURL(dsource)

Set Matches2 = regweb.Execute(dsource)

For Each Match2 In Matches2
sweb = Match2
Debug.Print result & dweb.Exists(result)
If dweb.Exists(result) = False Then
dweb.Add (result), 1
List2.AddItem result
Beep
End If
Next

Please check and help me.Thanks

2
Contributors
1
Reply
14
Views
2 Years
Discussion Span
Last Post by clairestreb
0
  1. At the top of your code, you should always use Option Explicit
  2. After that, add this comment: 'Requires Project Reference "Microsoft VBScript Regular Expressions 5.5"
  3. And 'Requires Project Component "Microsoft Internet Transfer Control 6.0"
  4. Replace your code with the following

    Dim iFile As Integer
    Dim dsource As String
    Dim result
    Dim regweb As Object
    Dim bBIN() As Byte
    dsource = "http://www.google.lt/search?num=100&q=" & Text2.Text
    Set regweb = New RegExp ' Create a regular expression.
    regweb.Pattern = "http://\b\w+\s\(net|com|us|org|ru|lt|co.uk|tr|info(ftp|telnet)*$"
    regweb.IgnoreCase = True ' Set case insensitivity.
    regweb.Global = True ' Set global applicability.
    bBIN = Inet1.OpenURL(dsource, icByteArray)
    iFile = FreeFile
    Open "C:\temp\temp.txt" For Binary Access Write As iFile
    Put #iFile, , bBIN
    Close iFile
    'Set Matches2 = regweb.Execute(dsource)
    'For Each Match2 In Matches2
    'sweb = Match2
    'Debug.Print result & dweb.Exists(result)
    'If dweb.Exists(result) = False Then
    'dweb.Add (result), 1
    'List2.AddItem result
    'Beep
    'End If
    'Next

  5. Examine the contents of C:\temp\temp.txt, and it will be very clear why the rest of your code was failing.

  6. In the future, I suggest you try better debugging techniques and reading the documentation before hobcobbling code together and pasting it on forums for others to do your work for you. For example, "Set Matches2 = regweb.Execute(dsource)" makes no sense at all. Good luck.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.