I need to check if in list2 is just present PASSWORD, if not add item PASSWORD.
naturally in my example not add item, just PASSWORD is in list2
check if value is in lisbox
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
check if value is in lisbox
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: check if value is in lisbox
Use code like this:
Code: Select all
Dim i As Long
Dim f As Boolean
For i = 0 To Me.List2.ListCount - 1
If Me.List2.List(i) = Me.List1 Then
f = True
Exit For
End If
Next i
If f = False Then
Me.List2.AddItem Me.List1
End If
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4362
- Joined: 26 Apr 2010, 17:36
Re: check if value is in lisbox
OPS...HansV wrote: ↑22 Jan 2021, 15:29Use code like this:
Code: Select all
Dim i As Long Dim f As Boolean For i = 0 To Me.List2.ListCount - 1 If Me.List2.List(i) = Me.List1 Then f = True Exit For End If Next i If f = False Then Me.List2.AddItem Me.List1 End If
the code work only if list2 is filled, but if not is filled?
-
- Administrator
- Posts: 78535
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands