mardi 11 juin 2019

stepping into condition even if sring is not same

I am a beginner in VB.NET. I am looping through a List of Vehicules and add indexes in STRING to another List if the numbers as Strings fit few conditions.

The first condition; If Not item.Equals("11652") still get into condition even if is not true;

Equals(), Not Equals(), Tostring.Equals

` Dim cpti = 0 For Each item In Vehicules.Items

            If ex = 1 Then

                If Not item.Equals("11652") Or item.ToString() <> "11785" Or item.ToString() <> "11814" Or item.ToString() <> "11852" Or item.ToString() <> "11853" Then

                    list.Add(cpti)


                End If



                If item.ToString() = "530011" Or item.ToString() = "530012" Or item.ToString() = "530013" Or item.ToString() = "530014" Or item.ToString() = "530015" Or item.ToString() = "530016" Or item.ToString() = "530017" Or item.ToString() = "530018" Or item.ToString() = "530019" Or item.ToString() = "530020" Then

                    list.Add(cpti)

                End If


            ElseIf ex = 3 Then

                If item.ToString() <> "326481" Or item.ToString() <> "326483" Or item.ToString() <> "326556" Or item.ToString() <> "326557" Then

                    list.Add(cpti)

                End If
            Else

                liste.Add(cpti)

            End If


        cpti = cpti + 1

    Next

`

Aucun commentaire:

Enregistrer un commentaire