General VB, i have a single column, multi-select listbox i am populating with file paths from components in an assembly. I need to add the path ONLY if it doesn't already exist.
i can either do it as i process the components of the assembly, or after the fact. I would prefer while. that being said the function below is giving me an error. of: "vba could not get the list property. invalid property array index"
Private Function AddListBoxItem(pathName As String) As Boolean
Dim x As Integer
For x = 0 To F1.Lb.ListCount
If LCase(pathName) = LCase(F1.Lb.List(x)) Then
'It Exists
F1.Lb.List(x) = pathName
AddListBoxItem = False
Exit For
Else
AddListBoxItem = True
End If
Next x
If AddListBoxItem = True Then
F1.Lb.AddItem pathName
Else
MsgBox "Item already exists"
End If
End Function
i thought (via a google searches) that using "contains" as below was supposed to compare, but contains was not avail.
F1.Lb.Items.Contains(pathName)
thoughts?
SolidworksApi/macros