Gruppe
Dialog
Problem
Wie kann ich Eintragungen in der einen Textbox auswählen und in die andere übertragen?
StandardModule: basMain
Sub CallForm()
frmMonths.Show
End Sub
ClassModule: frmMonths
Private Sub cmdContinue_Click()
Unload Me
End Sub
Private Sub cmdHin_Click()
Dim arr() As String
Dim var As Variant
Dim iRow As Integer
If lstTarget.ListCount > 0 Then
ReDim arr(1 To lstTarget.ListCount)
For iRow = 0 To lstTarget.ListCount - 1
arr(iRow + 1) = lstTarget.List(iRow)
Next iRow
For iRow = 0 To lstSource.ListCount - 1
If lstSource.Selected(iRow) Then
var = Application.Match(lstSource.List(iRow), arr, 0)
If IsError(var) Then
ReDim Preserve arr(1 To UBound(arr) + 1)
arr(UBound(arr)) = lstSource.List(iRow)
End If
End If
Next iRow
lstTarget.List = arr
Else
For iRow = 0 To lstSource.ListCount - 1
If lstSource.Selected(iRow) Then
lstTarget.AddItem lstSource.List(iRow)
End If
Next iRow
End If
End Sub
Private Sub cmdHer_Click()
Dim iRow As Integer
For iRow = lstTarget.ListCount - 1 To 0 Step -1
If lstTarget.Selected(iRow) Then
lstTarget.RemoveItem iRow
End If
Next iRow
End Sub
Private Sub cmdAll_Click()
lstTarget.List = lstSource.List
End Sub
Private Sub cmdRemove_Click()
lstTarget.Clear
End Sub
Private Sub lstTarget_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
lstTarget.RemoveItem lstTarget.ListIndex
End Sub
Private Sub lstSource_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Call cmdHin_Click
End Sub
Private Sub UserForm_Initialize()
Dim iMonth As Integer
For iMonth = 1 To 12
lstSource.AddItem Format(DateSerial(1, iMonth, 1), "mmmm")
Next iMonth
End Sub