''' <summary>
''' Return a list of Checked items from a checkedlistbox
''' if ValueMember=true the Checkedlistbox must the ValueMember property set to a field name and the valuemember will be returned.
''' if ValueMember=false will return the index of item in the CheckedListBox
''' ''' </summary>
''' <param name="CLB">The Checklistbox</param>
''' <param name="Valuemember">True/False</param>
''' <returns></returns>
Public Function GetCheckListBoxValues(ByRef CLB As CheckedListBox, Optional ByVal Valuemember As Boolean = False) As String()
GetCheckListBoxValues = Nothing
Try
If CLB.CheckedItems.Count > 0 Then 'Check to see if any objects in the list are checked.
Dim Int1 As Integer = 0 'Generic Counter
Dim Rtn(CLB.CheckedItems.Count - 1) As String 'Define a return variable
Dim fn As String = CLB.ValueMember 'if the Valuemember is being used the find the field name of the the Valuemember
For Each item As Data.DataRowView In CLB.CheckedItems 'Loop through each checked item
If IsNothing(item) Then Continue For
If Valuemember Then
Rtn(Int1) &= item.Item(fn).ToString 'Return the ValueMember
Else
Rtn(Int1) &= CLB.CheckedItems.IndexOf(item).ToString 'Return the index of the item
End If
Int1 += 1
Next
GetCheckListBoxValues = Rtn
End If
Catch ex As Exception
ex.Source = System.Reflection.MethodBase.GetCurrentMethod.Module.Name & "." & System.Reflection.MethodBase.GetCurrentMethod().Name
ErrLogging(ex)
End Try
End Function