私はこれに2日間取り組んできました。基本的に2つのリストボックスがあり、コマンドボタンで値を比較し、一致しない値(最初のリストボックスには表示されるが、2番目のリストボックスには表示されない)を表示して、3番目のリストボックスにリストする必要があります。これが最善の方法かどうかはわかりませんが、ここに私のコードがあります。次のメッセージの行でエラーが発生します。
引数の数が間違っているか、プロパティの割り当てが無効です
私のリストボックスの名前はCompList1、CompList2、CompList3です。
Dim BoolAdd As Boolean, I As Long, j As Long
'Set initial Flag
BoolAdd = True
'If CompList2 is empty then abort operation
If CompList2.ListCount = 0 Then
MsgBox "Nothing to compare"
Exit Sub
'If CompList1 is empty then copy entire CompList2 to CompList3
ElseIf CompList1.ListCount = 0 Then
For I = 0 To CompList2.ListCount
CompList3.AddItem CompList2.Value
Next I
Else
For I = CompList2.ListCount - 1 To 0 Step -1
For j = 0 To CompList1.ListCount
If CompList2.ListCount(I) = CompList1.ListCount(j) Then
'If match found then abort
BoolAdd = False
Exit For
End If
DoEvents
Next j
'If not found then add to CompList3
If BoolAdd = True Then CompList3.AddItem CompList2.Value
DoEvents
Next I
End If