VB - if avec plusieurs conditions

stick25 -  
 lokorn -
Bonjour,
je me permets de vous solliciter pour une tite question par très compliquée je pense mais dont je ne trouve pas la solution :

J'ai écris le code suivant mais les conditions de mes if pose pb...

Dim i, j As Integer
j = Liste.Lstb_pts.ListCount - 1
For i = 0 To j
If Liste.Lstb_pts.List(i, 3) = 0 And Liste.Lstb_pts.List(i - 1, 3) <> 0 Then
tdep = Lstb_pts.List(i - 1, 3)
End If
If Liste.Lstb_pts.List(i, 3) = 0 And Liste.Lstb_pts.List(i + 1, 3) <> 0 Then
tfin = Lstb_pts.List(i + 1, 3)
End If
Next

Label7 = tdep
Label8 = tfin


Merci de votre aide !!

23 réponses

  • 1
  • 2
  1. stick25
     
    Voila enfin un code qui marche, merci quand même pour ton implication.

    Dim i As Integer, j As Integer
        For i = 0 To Liste.Lstb_pts.ListCount - 1
            ' on cherche tdep
            If Liste.Lstb_pts.List(i, 3) = 0 And i > 0 Then
                tdep = Liste.Lstb_pts.List(i - 1, 3)
                Exit For
            End If
        Next i
        ' on cherche tfin
        For j = i + 1 To Liste.Lstb_pts.ListCount - 1
            If Liste.Lstb_pts.List(j, 3) <> 0 Then
                tfin = Liste.Lstb_pts.List(j, 3)
                Exit For
            End If
        Next j
    

    Il me reste maintenant à voir comment je vais gérer quand j'aurai plus d'une série de 0.
    2
  • 1
  • 2