Überprüfen, ob ein Item in einer ListBox schon vorhanden ist

  • VB.NET

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von SystemUnknow.

    Überprüfen, ob ein Item in einer ListBox schon vorhanden ist

    Ich willk uberprüfen, ob dieses Item mit dem Text von

    VB.NET-Quellcode

    1. temp2(UBound(temp2))


    in der ListBox

    VB.NET-Quellcode

    1. lstLables


    schon vorhanden ist.

    Momentan sieht es so aus:

    VB.NET-Quellcode

    1. If temp2(UBound(temp2)).StartsWith("Lbl ") ThenFor Each Ite As Object In lstLables.Items
    2. itemS = itemS + Ite
    3. MsgBox(Ite)
    4. Next
    5. If itemS.Contains((UBound(temp2))) = False Then
    6. lstLables.Items.Add(temp2(UBound(temp2)))
    7. End If
    8. End If
    Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.

    BeryJu.org BeryJu.org/Blog

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „JensMn“ ()

    Würde ich etwa so machen:

    VB.NET-Quellcode

    1. For i As Integer = 0 To 10
    2. ListBox1.Items.Add("Name " & i.ToString)
    3. Next
    4. For Each item As String In ListBox1.Items
    5. If item.Contains("Name 5") Then
    6. MsgBox(item & " gefunden")
    7. End If
    8. Next


    Also als reines Beispiel..^^
    Ich habe mich falsch ais gedrückt.
    Es soll eine IDE werden, und die ListBox eine Liste der Sprungmarken.
    Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.

    BeryJu.org BeryJu.org/Blog