Gruppe
Dialog
Problem
Die Felder einer ListBox sollen nach oben oder unten verschoben werden können.
ClassModule: frmMove
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdTop_Click()
Dim sTxt As String
If lstValues.ListIndex = -1 Then
Beep
MsgBox "Sie müssen ein Element auswählen"
Exit Sub
End If
With lstValues
If .ListIndex > 0 Then
sTxt = .List(.ListIndex - 1)
.List(.ListIndex - 1) = .List(.ListIndex)
.List(.ListIndex) = sTxt
.Selected(.ListIndex - 1) = True
End If
End With
End Sub
Private Sub cmdDown_Click()
Dim sTxt As String
If lstValues.ListIndex = -1 Then
Beep
MsgBox "Sie müssen ein Element auswählen"
Exit Sub
End If
With lstValues
If .ListIndex < .ListCount - 1 Then
sTxt = .List(.ListIndex + 1)
.List(.ListIndex + 1) = .List(.ListIndex)
.List(.ListIndex) = sTxt
.Selected(.ListIndex + 1) = True
End If
End With
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub UserForm_Initialize()
Dim iMonth As Integer
For iMonth = 1 To 12
lstValues.AddItem Format(DateSerial(1, iMonth, 1), "mmmm")
Next iMonth
End Sub
StandardModule: Modul1
Sub CallForm()
frmMove.Show
End Sub