Si potrebbe fare una cosa del genere:
Public Sub Main()
Dim s As String
Dim i As Integer
Dim ssA As String[] = ["Smith", "Anderson", "Clark", "Wright", "Mitchell", "Johnson", "Thomas", "Rodriguez"]
Dim ssB As String[] = ["Johnson", "Lopez", "Perez", "Wright", "Williams", "Smith", "Thomas", "Jones", "Anderson"]
For Each s In ssB
i = ssA.Find(s)
If i > -1 Then
ssA.Remove(i)
Endif
Next
ssB.Insert(ssA)
ssB.Sort()
For Each s In ssB
Print s
Next
End
Forte il metodo proposto da Minisini per eliminare i doppioni.
Per rimanere nella nostra semplificazione (anche se un po arzigogolato) lo si potrebbe scrivere così:
Dim cThemes As New Collection
Dim ssA As String[] = ["Johnson", "Lopez", "Perez", "Wright", "Williams", "Smith", "Thomas", "Jones", "Anderson"]
Dim ssB As String[] = ["Smith", "Anderson", "Clark", "Wright", "Mitchell", "Johnson", "Thomas", "Rodriguez"]
Dim aThemes As New String[]
Dim sTheme As String
Dim sDir As String
For Each sDir In ssA
cThemes[sDir] = True
Next
For Each sDir In ssB
cThemes[sDir] = True
Next
For Each cThemes
aThemes.Add(cThemes.Key)
Next
aThemes.Sort(gb.Ascent)
For Each sTheme In aThemes
Print sTheme
Next
Bel trucchetto (a me sconosciuto) :ok:
P.S. La discussione originale è qui (http://www.gambas-it.org/smf/index.php?topic=5881.msg42116#msg42116)