Die ausgewählten Items einer Listbox in String sichern
Public Sub SelectedFromStringToListBox(ByVal gesamtString As String, Liste As ListBox)
On Error GoTo Er
Dim v
Dim i As Integer
Dim j As Integer
With Liste
For Each v In .ItemsSelected
.Selected(v) = False
Next v
v = Split(gesamtString, "; ")
For i = 0 To UBound(v)
For j = 0 To .ListCount - 1
If v(i) = .ItemData(j) Then
.Selected(j) = True
Exit For
End If
Next j
Next i
End With
Ex: Exit Sub
Er: MsgBox "Fehler " & Err.Number & " in SelectedFromStringToListBox" _
& vbCrLf & Err.Description
Resume Ex
End Sub
Public Function SelectedFromListbox(ByVal Liste As ListBox) As String
On Error GoTo Er
Dim s As String
Dim v
s = ""
For Each v In Liste.ItemsSelected
If s > "" Then s = s & "; "
s = s & Liste.ItemData(v)
Next v
Ex:
SelectedFromListbox = s
Exit Function
Er: MsgBox "Fehler " & Err.Number & " in SelectedFromListbox" _
& vbCrLf & Err.Description
s = ""
Resume Ex
End Function

On Error GoTo Er
Dim v
Dim i As Integer
Dim j As Integer
With Liste
For Each v In .ItemsSelected
.Selected(v) = False
Next v
v = Split(gesamtString, "; ")
For i = 0 To UBound(v)
For j = 0 To .ListCount - 1
If v(i) = .ItemData(j) Then
.Selected(j) = True
Exit For
End If
Next j
Next i
End With
Ex: Exit Sub
Er: MsgBox "Fehler " & Err.Number & " in SelectedFromStringToListBox" _
& vbCrLf & Err.Description
Resume Ex
End Sub
Public Function SelectedFromListbox(ByVal Liste As ListBox) As String
On Error GoTo Er
Dim s As String
Dim v
s = ""
For Each v In Liste.ItemsSelected
If s > "" Then s = s & "; "
s = s & Liste.ItemData(v)
Next v
Ex:
SelectedFromListbox = s
Exit Function
Er: MsgBox "Fehler " & Err.Number & " in SelectedFromListbox" _
& vbCrLf & Err.Description
s = ""
Resume Ex
End Function



0 Kommentare:
Kommentar veröffentlichen
Links zu diesem Post:
Link erstellen
<< Startseite