NON EXECUTION DE BOUCLE

Résolu
winvsmac Messages postés 84 Date d'inscription samedi 26 mai 2007 Statut Membre Dernière intervention 14 décembre 2016 - 3 févr. 2010 à 00:20
us_30 Messages postés 2065 Date d'inscription lundi 11 avril 2005 Statut Membre Dernière intervention 14 mars 2016 - 3 févr. 2010 à 09:06
Bonjour,

Je poste ce message car je bloque sur une broutille.
Environnement VB6.

Soit le code suivant :

Dim myvalue, myvalue2 As String
Dim nb_ligne As Integer
Dim XX As Integer

nb_ligne = FICHECHANTIER.MS.Rows
FICHECHANTIER.MS.Col = 0
FICHECHANTIER.MS.Row = 0

For i = 0 To liste_date.ListCount - 1
    myvalue = liste_date.List(i)
    For X = 3 To 2 + liste_date.ListCount
        FICHECHANTIER.MS.Col = X
        If FICHECHANTIER.MS.Text = myvalue Then
            MsgBox myvalue & " " & FICHECHANTIER.MS.Col
        End If
    Next X
Next i

myvalue = ""

For i = 0 To liste_article.ListCount - 1
    myvalue = liste_article.List(i)
    For X = 1 To nb_ligne - 1
        FICHECHANTIER.MS.Row = X
        If FICHECHANTIER.MS.Text = myvalue Then
            MsgBox myvalue & " " & FICHECHANTIER.MS.Row
        End If
    Next X
Next i


Si j'exécute le code tel quel, la 1ère boucle for i/next i fonctionne, mais, al seconde boucle ne s'execute pas.

Si je mets en commentaire la 1ere boucle, la 2nde s'exécute, et inversement.

Je ne comprends pas pourquoi 2 boucles ne veulent pas s'exécuter a la suite.

Merci pour vos pistes.

Jerome

1 réponse

us_30 Messages postés 2065 Date d'inscription lundi 11 avril 2005 Statut Membre Dernière intervention 14 mars 2016 10
3 févr. 2010 à 09:06
Bonjour,

Que veux-tu dire par boucle ? Tu désignes les boucles imbriquées ou les deux boucle FOR i=...

Remarque 1 :
Dim XX As Integer

semble incorrect :
Dim X As Integer


Piste de réflexion :
Test ce que vaut les bornes des boucle FOR, juste avant qu'elles s'exécutent.

'msgbox liste_date.ListCount - 1 'doit être >=0
For i = 0 To liste_date.ListCount - 1
    myvalue = liste_date.List(i)

'msgbox 2 + liste_date.ListCount 'doit être >= 3
    For X = 3 To 2 + liste_date.ListCount
        FICHECHANTIER.MS.Col = X
        If FICHECHANTIER.MS.Text = myvalue Then
            MsgBox myvalue & " " & FICHECHANTIER.MS.Col
        End If
    Next X
Next i


etc...

Amicalement,
Us.
3
Rejoignez-nous