+ Reply to Thread + Post New Thread
Results 1 to 2 of 2

Thread: Merging two Textboxes + Deleting duplicates

  1. #1
    Noobie
    Join Date
    Apr 2008
    Posts
    82
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Merging two Textboxes + Deleting duplicates

    I have been trying in vain to do the following:

    Textbox A: Has hundreds of Youtube Video IDs
    Textbox B: Has less Youtube Video IDs

    I want to click a button and then have a new text box populated with all the Video IDs in textbox A that are NOT in Textbox B... sounds simple...

    So far ive made two arrays and a nested for next loop, it's not working as i want though which is frustrating.

    I'm willing to pay for your trouble if someone can get this working, and give me commented code so i understand what's going on.

    My code so far:

    Code:
    Dim splitIDs, splitMerged
    ** *Dim temp, temp2 As String
    ** *Dim foundMatch As Boolean
    ** *Dim retval As Integer
    ** *
    ** *splitIDs = Split(TextIDs.Text, vbCrLf) ' *This is Textbox A
    ** *splitMerged = Split(TextMerged.Text, vbCrLf) ' *This is Textbox B
    ** *
    ** *For x = 0 To UBound(splitIDs)
    ** *
    ** * * *temp = splitIDs(x)
    ** *
    ** * * * * *For y = 0 To UBound(splitMerged)
    ** * * * * *
    ** * * * * * * *temp2 = splitMerged(y)
    ** * * * * * * *
    ** * * * * * * *Log ("temp *is: " & temp)
    ** * * * * * * *Log ("temp2 is: " & temp2)
    ** * * * * * * *
    ** * * * * * * *retval = InStr(1, temp, temp2) ' Returns 1 if match, 0 if not
    ** * * * * * * *
    ** * * * * * * *Log ("Result for compare was: " & retval)
    ** * * * * * * *
    ** * * * * * * *Select Case retval
    ** * * * * * * * * *Case 0:
    ** * * * * * * * * * * *foundMatch = False
    ** * * * * * * * * * * *Log ("I think " & temp & " & " & temp2 & " are different")
    ** * * * * * * * * * * *TextResult.Text = TextResult.Text & vbCrLf & temp
    ** * * * * * * * * *Case 1:
    ** * * * * * * * * * * *Log ("I think " & temp & " & " & temp2 & " are same")
    ** * * * * * * * * * * *foundMatch = True: Exit For
    ** * * * * * * *End Select * * * *
    ** * * * * *Next y * 
    ** *Next x
    It occasionally throws a 1, even though they arent the same, and debugging it i see it's because sometimes it reads a blank space from "TextBox B"
    Plus it prints LOADS of each one, when it shouldnt...

    It's a long shot asking for help but i'm pulling my hair out

    Thanks

  2. #2
    Noobie
    Join Date
    Apr 2008
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    Private Sub Command1_Click()
    ** *Dim ItsThere As Boolean
    ** *For i = 0 To List1.ListCount - 1
    ** * * *For x = 0 To List2.ListCount - 1
    ** * * * * *If List1.List(i) = List2.List(x) Then
    ** * * * * * * *ItsThere = True
    ** * * * * *End If
    ** * * *Next
    ** * * *If ItsThere = True Then
    ** * * * * *'do nothing...
    ** * * *Else
    ** * * * * *List3.AddItem List1.List(i)
    ** * * *End If
    ** * * *ItsThere = False
    ** *Next
    End Sub
    
    Private Sub Form_Load()
    ** *List1.AddItem "a"
    ** *List1.AddItem "b"
    ** *List1.AddItem "c"
    ** *List1.AddItem "d"
    ** *List1.AddItem "e"
    ** *List1.AddItem "f"
    ** *List1.AddItem "g"
    ** *List1.AddItem "h"
    ** *List1.AddItem "i"
    ** *List1.AddItem "j"
    ** *List1.AddItem "k"
    ** *
    ** *
    ** *
    ** *List2.AddItem "b"
    ** *List2.AddItem "d"
    ** *List2.AddItem "k"
    ** *List2.AddItem "g"
    End Sub

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts