IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB 6 et antérieur Discussion :

Problème avec Loop vb6


Sujet :

VB 6 et antérieur

  1. #1
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    89
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 89
    Par défaut Problème avec Loop vb6
    Bonjour à tous,

    Je suis face avec un preblème de loop until en vb6

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Private Sub Command4_Click()
     
    Do Until Combo4.List < 0
       Combo4.ListIndex = Combo4.ListIndex + 1
     
     
    'Série de fonction non marqué ...........
     
     
    Loop
    MsgBox "fin"
    End Sub
    La loop se fait avec le Combo4. Il dois passer 1 par 1, à travers la liste du combo4. Une fois la fin de la liste atteint, la loop se termine et il me dit que la liste est complété ex:
    Merci encore pour votre aide.

  2. #2
    Inactif  

    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    4 555
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 4 555
    Par défaut
    Bonsoir,

    la lecture de ton aide en ligne t'apprend que la propriété List attend un argument (un index).
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Do Until Combo4.List < 0
    a nécessairement provoqué d'emblée un message d'erreur que tu nous passes sous silence !

    Regarde ceci (et relis ton aide en ligne) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    For i = Combo4.ListIndex To Combo4.ListCount - 2
      Combo4.ListIndex = Combo4.ListIndex + 1
      MsgBox Combo4.List(Combo4.ListIndex)
    Next
    Démarrera à l'index sélectionné et ira jusqu'à la fin

    EDIT : as-tu installé MSDN ?
    Si non et que tu ne l'as pas : Progelect t'a (dans une autre discussion) donné un lien pour te permettre de l'installer (en français) :

  3. #3
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    89
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 89
    Par défaut
    C'est vrai, j'ai l'error Compile error 380
    argument not optimal.

    Étant débutant, quand je fais F1, j'ai lus les information sans vraiment comprendre quelque chose.

    Dans les example, il n'y a rien qui ressemble a quelque chose qui pourait s'adapter.

  4. #4
    Inactif  

    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    4 555
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2007
    Messages : 4 555
    Par défaut
    Apprendre à connaître un contrôle, c'est :
    - ouvrir ton aide en ligne sur ce contrôle pour en connaître les évènement, propriétés et méthodes
    - puis apprendre chacun de ses évènements, chacune de ses propriétés et chacune de ses méthodes (aide en ligne à nouveau), généralement assortis d'exemples....

    Mais je pense t'avoir donné une solution, non ?

    en voilà une autre, avec une boucle while until :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Do Until Combo4.ListIndex = Combo4.ListCount - 1
       Combo4.ListIndex = Combo4.ListIndex + 1
       MsgBox Combo4.List(Combo4.ListIndex)
    Loop
    EDIT :
    Il est également important de bien lire et nous rapporter, lorsque tu nous exposes un problème, le(s) message(s) d'erreur reçu(s) (en nous précisant la ligne qui le(s) génère).
    Bien lire, signifie par exemple qu'on examine le message avec soin et qu'on l'analyse.
    Par exemple, ici :
    Citation Envoyé par avyrex Voir le message
    C'est vrai, j'ai l'error Compile error 380
    argument not optimal.
    "optimal" n'est pas le mot qui se trouvait dans ton message d'erreur
    (et il a une autre signification, très différente, que celle de l'adjectif qui s'y trouvait et qui, lui, dénonçait clairement une absence ...)
    Le debugger dénonçait alors sur le mot List, n'est-ce-pas ? Un simple coup de F1 sur ce mot t'aurait conduit alors à la propriété List (ton aide en ligne) et t'aurait permis de découvrir sa syntaxe (qui attend un index).

  5. #5
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    89
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 89
    Par défaut
    Avec ton aide, je crois que j'y suis presque.

    Maintenant, il fait la loop, parcontre il n'arrete pas quand le Combo4 est vide.

    Voici le code entier:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    Private Sub Command4_Click()
    Do Until Combo4.ListIndex = Combo4.ListCount - 1
     
       'insert code
    MSFlexGrid1.ColWidth(0) = 1500
    MSFlexGrid1.AddItem "H" & vbTab & Combo1.Text & vbTab & "M" & Combo7 & "00" & Text2 & vbTab & Combo2 & vbTab & "HOST" & vbTab & Combo3 & vbTab & Combo4 & vbTab & vbTab & vbTab & Text10 & vbTab & Text11 & vbTab & Text12 & vbTab & Text13 & vbTab & Combo5 & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "COL" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "M" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "P" & vbTab & vbTab & "M" & Combo7 & "00" & Text2 & vbTab & Combo2 & vbTab & Text16 & vbTab & Text14 & vbTab & Text9 & vbTab & vbTab & vbTab & vbTab & Combo6
     
    'augmanter le nombre de commande
    Text5 = Text5 + 1
     
    FlexGrid_AutoSizeColumns MSFlexGrid1, Me
     
    Text2 = Text2 + 1
     
    'next orders
    Combo4.ListIndex = Combo4.ListIndex + 1
     
    Frame2.Visible = True
    MSFlexGrid1.Visible = True
     
     
    'Insert pieces and cubes for the store
     Dim i As Integer
      For i = 0 To Order_LakeShore.MSFlexGrid1.Rows - 1
         If New_order.Combo4.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 1) Then
            'MsgBox "Found: " & Order_LakeShore.MSFlexGrid1.TextMatrix(i, 1) & ": " & Order_LakeShore.MSFlexGrid1.TextMatrix(i, 21)
            Text9.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 20)
            Text16.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 21)
            Text4.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 22)
            Label18 = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 0)
         End If
      Next
     
     'Insert windows for the store
     Dim j As Integer
      For j = 0 To LakeShore.MSFlexGrid1.Rows - 1
         If New_order.Combo4.Text = LakeShore.MSFlexGrid1.TextMatrix(j, 0) Then
            'MsgBox "Found: " & Order_LakeShore.MSFlexGrid1.TextMatrix(j, 1) & ": " & Order_LakeShore.MSFlexGrid1.TextMatrix(i, 21)
            Text10.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 2)
            Text11.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 3)
            Text12.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 2)
            Text13.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 3)      
     
         End If
      Next
    Loop
    End Sub

  6. #6
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    89
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 89
    Par défaut
    Super, ce fut long mais j'ai trouvé.

    Verdicte final:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    Private Sub Command4_Click()
       Dim w   As Integer
       For w = 0 To Combo4.ListCount - 1   ' Parcourt la
                                        ' liste dans
                                        ' la boucle.
          If Combo4 > "" Then
                'insert code
    MSFlexGrid1.ColWidth(0) = 1500
    MSFlexGrid1.AddItem "H" & vbTab & Combo1.Text & vbTab & "M" & Combo7 & "00" & Text2 & vbTab & Combo2 & vbTab & "HOST" & vbTab & Combo3 & vbTab & Combo4 & vbTab & vbTab & vbTab & Text10 & vbTab & Text11 & vbTab & Text12 & vbTab & Text13 & vbTab & Combo5 & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "COL" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "M" & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & "P" & vbTab & vbTab & "M" & Combo7 & "00" & Text2 & vbTab & Combo2 & vbTab & Text16 & vbTab & Text14 & vbTab & Text9 & vbTab & vbTab & vbTab & vbTab & Combo6
     
    'augmanter le nombre de commande
    Text5 = Text5 + 1
     
    FlexGrid_AutoSizeColumns MSFlexGrid1, Me
     
    Text2 = Text2 + 1
     
    'next orders
    Combo4.ListIndex = Combo4.ListIndex + 1
     
    Frame2.Visible = True
    MSFlexGrid1.Visible = True
     
     
    'Insert pieces and cubes for the store
     Dim i As Integer
      For i = 0 To Order_LakeShore.MSFlexGrid1.Rows - 1
         If New_order.Combo4.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 1) Then
            'MsgBox "Found: " & Order_LakeShore.MSFlexGrid1.TextMatrix(i, 1) & ": " & Order_LakeShore.MSFlexGrid1.TextMatrix(i, 21)
            Text9.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 20)
            Text16.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 21)
            Text4.Text = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 22)
            Label18 = Order_LakeShore.MSFlexGrid1.TextMatrix(i, 0)
         End If
      Next
     
     'Insert windows for the store
     Dim j As Integer
      For j = 0 To LakeShore.MSFlexGrid1.Rows - 1
         If New_order.Combo4.Text = LakeShore.MSFlexGrid1.TextMatrix(j, 0) Then
            'MsgBox "Found: " & Order_LakeShore.MSFlexGrid1.TextMatrix(j, 1) & ": " & Order_LakeShore.MSFlexGrid1.TextMatrix(i, 21)
            Text10.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 2)
            Text11.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 3)
            Text12.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 2)
            Text13.Text = Text3 & Text6 & Text14 & LakeShore.MSFlexGrid1.TextMatrix(j, 3)
     
     
         End If
      Next
     
     
          Else
     
          End If
       Next w
    End Sub

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [VBA] Problème avec composant VB6
    Par Diablo_22 dans le forum Général VBA
    Réponses: 8
    Dernier message: 16/03/2006, 20h41
  2. [VB6] Problème avec insertion d'icônes dans menu
    Par marsup54 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 02/03/2006, 21h38
  3. [VB6] Problème avec la touche 0 dans une MaskEdBox
    Par bb62 dans le forum VB 6 et antérieur
    Réponses: 2
    Dernier message: 02/03/2006, 09h47
  4. [VB6] Problème avec requête Update
    Par bb62 dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 02/02/2006, 03h40
  5. Petit problème avec vb6 et mysql
    Par AsmCode dans le forum SQL Procédural
    Réponses: 2
    Dernier message: 05/01/2006, 04h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo