Sammenligning, output mv.
Jeg vil lave et program der sammenligner 2 strenge (indeholdende links), lægger linksene i arrays, sammenligner de 2 arrays og udskriver det link, som ikke eksisterer i det første array. Her er hvad jeg har foreløbig og det spiller ikke rigtigt, håber I kan hjælpe mig lidt med det jeg allerede har.På forhånd tak!
Option Explicit
Dim ref1 As String
Dim ref2 As String
Dim i As Integer
Dim n As Integer
Dim t As Integer
Dim s As Integer
Dim links1 As Variant
Dim links2 As Variant
Dim newlinks() As String
Dim foundit As Boolean
Dim re As New RegExp
Private Sub Command1_Click()
FindLinks
CompareURLs
End Sub
Private Sub Command2_Click()
FindLinks
End Sub
Private Sub Form_Load()
ReDim newlinks(0)
ref1 = "Lorem ipsum. <a href=""http://www.hej.com"">hej.com</a>. Lorem."
ref2 = "Lorem ipsum. <a href=""http://www.hej.com"">hej.com</a><a href=""http://www.nesdafj.com"">neja.com</a>. Lorem."
End Sub
Private Sub CompareURLs()
MsgBox (links2.Count)
For i = 0 To links2.Count
foundit = False
For n = 0 To links1.Count
If links2(i) = links1(n) Then
foundit = True
End If
Next n
If foundit = False Then
If newlinks(0) <> "" Then
ReDim Preserve newlinks(UBound(newlinks) + 1)
Else
ReDim Preserve newlinks(0)
End If
newlinks(UBound(newlinks)) = links2(i)
End If
Next i
Popup
End Sub
Private Sub FindLinks()
Set re = New RegExp
re.Global = True
re.Pattern = "<a[^<]*</a>"
Set links1 = re.Execute(ref1)
Set links2 = re.Execute(ref2)
MsgBox (links1(0))
End Sub
Private Sub Popup()
For t = 0 To UBound(newlinks)
MsgBox ("hej: " & newlinks(t))
Next t
End Sub
