我確實有1個大陣列+ -11000000個元素。我需要做的是刪除這個數組中的重複項。我所做的是將第一個數組複製到第二個數組。然後,我從數組1的元素0開始,並將該元素與第二個數組中的每個元素進行循環比較。如果它發現重複,它會在重複元素處的第二個數組中寫入一個空字符串。 這讓我感到困惑,因爲當我運行數組2時,我拿起一個重複的數據,然後在檢查下一個元素的時候將它計爲1(它注意到這個重複與第一個重複不一樣) 2,它刪除那個錯誤的元素。我結束了一個空陣列。 見代碼:我需要比較2個數組與vb.net中的相同值
Dim X As Long = 0
Dim Y As Long = 0
Dim Z As Long = 0
Dim A As Integer = 0
Dim FileNo As Integer = 1
Me.Hide()
Me.Visible = False
NotifyIcon1.Visible = True
For X = 0 To UBound(arrToCheck)
Btn2.Text = " Busy with Line " & X
NotifyIcon1.Text = Btn2.Text
My.Application.DoEvents()
For Y = 0 To UBound(arrToCompare)
Btn5.Text = "arrTocompare " & Y
My.Application.DoEvents()
If Trim(arrToCheck(X)) = Trim(arrToCompare(Y)) Then
A = A + 1
If A >= 2 Then
arrToCompare(Y) = ""
My.Application.DoEvents()
End If
A = 0
' A = A + 1
End If
My.Application.DoEvents()
Next
My.Application.DoEvents()
Next
陣列小例子
AMERIKAANSE AMERIKAANSE 馬薩
結果必然是 AMERIKAANSE 馬薩enter code here