·  Start ·  Programme ·  Codes ·  Tipps ·  ActiveX ·  Tutorials · 



Hier werden Einträge in die Liste der Combobox hinzugefügt. Bequemerweise gleich mit Tastendruck auf "Enter". Gleichzeitig wird aber überprüft, ob dieser Eintrag nicht bereits vorhanden ist.
Sie benötigen 1 Formular und eine Combobox, Style=0

' Hinzufügen von Einträgen in eine Combobox
' Mit gleichzeitiger Abfrage, ob diese Einträge bereits
' existieren. Wenn nicht, kommt der Eintrag hinzu.

Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyReturn
        If ExistComboEntry(Combo1, Combo1.Text) = False Then
            Combo1.AddItem Combo1.Text
            Combo1.Text = "" ' Eingabefeld leeren
        Else
            MsgBox "Eintrag bereits vorhanden"
        End If
    End Select
End Sub

Private Function ExistComboEntry(CBO As ComboBox, cboText As String) As Boolean
Dim i As Integer
    For i = 0 To CBO.ListCount - 1
        If CBO.List(i) = cboText Then
            ExistComboEntry = True
            Exit Function
        End If
        ExistComboEntry = False
    Next 'i
End Function
Aktualisiert: 12.02.2008, 14:11 Uhr Copyright © 2001 - 2010 by ST-software Navigation zurück  |  Navigation vorwärts  |  Zum Seitenanfang     
Ihre IP: 38.107.191.83 ·  Seite erstellt in: 0.549 Sekunden ·  Dateigröße:  2988 Bytes