VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



How to use listbox with checkbox style how to store selected items in a single field and how to ret

by [email protected] (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 2nd March 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

How to use listbox with checkbox style how to store selected items in a single field and how to retrieve to select back

Rate How to use listbox with checkbox style how to store selected items in a single field and how to ret



'To Store selected Listbox items

Function GetSelected() As String
Dim str As String
str = ""
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then

'MID function is used becz listbox is loaded with more than one column

str = str & Trim(Mid(List1.List(i), 1, 6)) & ":" 
End If
Next
If Len(str) > 0 Then
str = Mid(str, 1, Len(str) - 1)
Else
str = "No Equipment"
End If
GetSelected = str
End Function


'To Select back

Sub SelectItems(ste As String)
If ste = "No Equipment" Then
Else
Dim bs
bs = Split(ste, ":")
For i = 0 To UBound(bs)
For j = 0 To List1.ListCount - 1
If bs(i) = Trim(Mid(List1.List(j), 1, 6)) Then
On Error Resume Next
List1.Selected(j) = True
End If
Next
Next
End If
End Sub


Download this snippet    Add to My Saved Code

How to use listbox with checkbox style how to store selected items in a single field and how to ret Comments

No comments have been posted about How to use listbox with checkbox style how to store selected items in a single field and how to ret. Why not be the first to post a comment about How to use listbox with checkbox style how to store selected items in a single field and how to ret.

Post your comment

Subject:
Message:
0/1000 characters