Additionner click commandbutton vers textbox

Je vois que tu as été confronté au même problème que moi > quand une table est foncée > l'on ne peut plus cliquer dessus > car l'image pâle se nomme "Image X" et l'image foncée se nomme "Image Xb" ...

C'est corrigé sur la version 8b ...

Bonjour,

En fin de compte > seule la table 1 fonctionne > désolé ...

Je regarde ...

ric

Bonjour Ric,

Concernant le soucis avec le bouton cash, le soucis est avec les tables mais aussi avec le nom des clients

Bonjour,

Je croyais tout cela réglé > mais le fichier a planté à quelques reprises > je sûrement tout perdu ...

Je recommence > l'on se revoit demain ...

ric

Bonjour,

Merci

Te souhaite une bonne fin de journée.

A demain

Bonjour Ric,

Suis dégouté, j'ai l'impression de revenir 2mois en arrière avec le bouton cash

Mais bon, vais pas me laisser décourager

Heureusement que tu es la pour m'aider et pour m'encourager

Encore merci

Bonjour,

Il ne faut pas voir cela négativement > il faut voir cela comme un apprentissage et tous les apprentissages ont des écueils à traverser ...

C'est formateur ...

Je me retrouve avec plusieurs irritants qui m'empêchent d'avancer rapidement dans le dépannage de ce cas là ...

À dire qu’hier > à part le listbox2 > tout fonctionnait bien > je ne sais pas quelle manipulation ai-je faite > j'ai tout perdu ...

Il ne reste qu'à recommencer ...

Dès que j'ai du concret > je reviens ...

ric

Bonjour Ric,

Merci de me motiver, ça fais plaisir

Vais recommencer le codage du bouton et je croise le doigt

Bonjour Ric,

Grace à toi de m'avoir remotiver, je crois avoir trouver le soucis.

Je cale juste pour un code.

Quand je fais un nouveau client (bouton nouveau compte) et après validation, celui-ci apparait dans le listbox 1 seul

Quand je prend commande et le valide par cash directement, j'ai une erreur (pareil si je choisi une table)

J'espère m'être bien fais comprendre

Merci

4separationv13.xlsm (124.35 Ko)

Bonjour Ric,

Je crois, pour palier ce Buck il faudrait faire une condition dans le bouton cash

Si textbox8 = non d'un client ou nom de la table et qu'il n'y a que la listbox1 then

le cash fonctionne

else

on place tous le reste du code

Suis pas sur

T'en pense quoi?

Merci

Bonjour,

Encore une fois > je regarde ton fichier et tu regardes le mien ...

L'on se réécrit ...

ric

8separationv14.xlsm (150.05 Ko)

Bonjour,

Ton bogue provient qu'il n'y a pas de vérification si les nx (nombre de lignes) sont vides zou pas avant d'écrire le tableau ...

If n4 > 0 Then .Range("A" & Dlig3 + 1).Resize(n4, k4).Value = Tbl4

ric

Bonjour Ric,

Je regarde directement

Merci

Bonjour Ric,

J'ai un soucis avec la mise en page d'un code.

J'aimerais avec le bouton supprimer ligne dans listbox qu'on avais fait

Private Sub Supprimer_ligne_listbox_Click()
    'Supprimer ligne selectionnée dans listbox
If Me.ListBox1.ListIndex = -1 Then   ' << Si aucune sélection
        MsgBox "Veuillez selectionner une ligne", _
               vbExclamation + vbOKOnly, "ATTENTION !"
    Else                                ' sinon, supprimer la sélection
        Me.ListBox1.RemoveItem (Me.ListBox1.ListIndex)
    End If
    Me.ListBox1.ListIndex = -1         ' désélectionner après suppression
End Sub

J'aurais aimé que le bouton fonctionne pour les deux listbox

Du style:

si je sélectionne une ligne dans listbox1, elle me la supprime et si je sélectionne une ligne dans listbox2, elle me la supprime bien entendu avec la condition si aucune ligne sélectionné, un message apparait.

J'arrive facilement avec deux bouton, du style supprimer listbox1 et supprimer listbox2

Je me demander si c'était possible de le faire avec seulement le même bouton

En te remerciant

ps: j'espère que tous ce passe bien pour toi

Bonjour,

Un essai ...

Private Sub Supprimer_ligne_listbox_Click()
    'Supprimer ligne selectionnée dans listbox
If Me.ListBox1.ListIndex = -1 And Me.ListBox2.ListIndex = -1 Then   ' << Si aucune sélection
        MsgBox "Veuillez selectionner une ligne d'une listbox ", _
               vbExclamation + vbOKOnly, "ATTENTION !"

        ' sinon, supprimer la sélection
    Else
        If Me.ListBox1.ListIndex <> -1 Then
            Me.ListBox1.RemoveItem (Me.ListBox1.ListIndex)
            Me.ListBox1.ListIndex = -1         ' désélectionner après suppression
            Exit Sub
        End If
        If Me.ListBox2.ListIndex <> -1 Then Me.ListBox2.RemoveItem (Me.ListBox2.ListIndex)
    Me.ListBox2.ListIndex = -1         ' désélectionner après suppression
    End If
End Sub

Le projet avance-t-il à ton goût ?

ric

Bonjour Ric,

Encore un grand merci, je regarde directement.

Concernant le projet, il avance doucement mais surement

Merci

Re,

C'est super, c'est ce que je cherchais pour améliorer ce bouton.

Je t'explique ce que j'aimerais en faire.

Concernant la listbox1 rien ne change, on supprime bêtement car ce n'ai pas encore sauvegardé.

Concernant la listbox2, un peu plus compliqué car c'est sauvegarder et pas envie de faire seulement un suppression de ligne car ça fausserer qq résultat.

Pour que tous correspond, j'aimerais que quand je supprime dans la listbox2, quand je clic dessus sa me marque ce que j'ai supprimer.

Exemple:

contenu listbox2

4 coca 10 40

4 fanta 1.5 6

quand je clic sur coca (le résultat de ma listbox2 serais)

3 coca 10 30

4 fanta 1.5 6

1 coca 10 10 (en rouge)

Qu'en penses-tu,

Boujour Ric,

Je crois avoir trouver

voila le code que j'ai fais (me suis basé sur le bouton transfert compte)

Dim x As Integer
'Supprimer ligne selectionnée dans listbox
If Me.ListBox1.ListIndex = -1 And Me.ListBox2.ListIndex = -1 Then   ' << Si aucune sélection
        MsgBox "Veuillez selectionner une ligne d'une listbox ", _
               vbExclamation + vbOKOnly, "ATTENTION !"

        ' sinon, supprimer la sélection
Else
        If Me.ListBox1.ListIndex <> -1 Then
            Me.ListBox1.RemoveItem (Me.ListBox1.ListIndex)
            Me.ListBox1.ListIndex = -1         ' désélectionner après suppression
            Exit Sub
        End If
        If Me.ListBox2.ListIndex <> -1 Then

If Me.ListBox2.ListIndex = -1 Then Exit Sub

    If Me.ListBox1.ListCount > 0 Then
        For x = 0 To Me.ListBox1.ListCount - 1
            If Me.ListBox2.Column(1, Me.ListBox2.ListIndex) = Me.ListBox1.Column(1, x) Then
            Me.ListBox1.Column(0, x) = Me.ListBox1.Column(0, x) + 1
            Me.ListBox1.Column(2, x) = Me.ListBox2.List(Me.ListBox2.ListIndex, 2)

            Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = Me.ListBox2.List(Me.ListBox2.ListIndex, 0) - 1

            On Error Resume Next
            If Me.ListBox2.Column(3, Me.ListBox2.ListIndex) - Me.ListBox2.Column(2, Me.ListBox2.ListIndex) >= 0 Then
                Me.ListBox1.Column(3, x) = CDbl(Me.ListBox1.Column(3, x)) + CDbl(Me.ListBox2.Column(2, Me.ListBox2.ListIndex))
                Me.ListBox2.Column(3, Me.ListBox2.ListIndex) = CDbl(Me.ListBox2.Column(3, Me.ListBox2.ListIndex)) - _
               CDbl(Me.ListBox2.Column(2, Me.ListBox2.ListIndex))
            End If
            On Error GoTo 0
            If Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = 0 Then Me.ListBox2.RemoveItem Me.ListBox2.ListIndex
            Exit Sub
            End If
         Next x

    Me.ListBox1.AddItem
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 0) = 1
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Me.ListBox2.Column(1, Me.ListBox2.ListIndex)
    Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = Me.ListBox2.List(Me.ListBox2.ListIndex, 0) - 1
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = Me.ListBox2.Column(4, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = Me.ListBox2.Column(5, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = Me.ListBox2.Column(6, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = Me.ListBox2.Column(7, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = Me.ListBox2.Column(8, Me.ListBox2.ListIndex)

   If Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = 0 Then Me.ListBox2.RemoveItem Me.ListBox2.ListIndex ' <<< ajout

Else
    Me.ListBox1.AddItem
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 0) = 1
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Me.ListBox2.Column(1, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = Me.ListBox2.Column(4, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = Me.ListBox2.Column(5, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = Me.ListBox2.Column(6, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = Me.ListBox2.Column(7, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = Me.ListBox2.Column(8, Me.ListBox2.ListIndex)

    On Error Resume Next
    If Me.ListBox2.Column(3, Me.ListBox2.ListIndex) - Me.ListBox2.Column(2, Me.ListBox2.ListIndex) >= 0 Then
        Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = CDbl(Me.ListBox2.Column(2, Me.ListBox2.ListIndex))
        Me.ListBox2.Column(3, Me.ListBox2.ListIndex) = CDbl(Me.ListBox2.Column(3, Me.ListBox2.ListIndex)) - _
                Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    End If
    On Error GoTo 0
    Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = Me.ListBox2.List(Me.ListBox2.ListIndex, 0) - 1

    If Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = 0 Then Me.ListBox2.RemoveItem Me.ListBox2.ListIndex ' <<< ajout

If MsgBox("Avez-vous fini la suppression?", vbQuestion + vbYesNo, "ATTENTION !!!") = vbYesNo Then
End If
End If

    Me.ListBox2.ListIndex = -1         ' désélectionner après suppression
    End If
End If

Le principe est que quand je sélection pour la suppression dans listbox2, ça me met ce que j'ai supprimer dans la listbox1 pour vérifier.

Bien entendu sa fait la modification dans listbox2 et listbox1 en même temps

J'ai juste un soucis pour mon msgbox, je crois que je l'ai mal placer.

Mon msgbox qui marche qu'une fois et j'aimerais qu'elle aparait à chaque fois que je clic pour la suppression.

Comme tu peux le constater j'ai pas encore mis de fonction dans ma msgbox, j'aimerais résoudre le soucis de son apparition après chaque suppression.

En te remerciant encore pour ton aide

Re,

Voila je crois avoir trouver j'ai rajouter 2 emplacement pour le msgbox

Private Sub Supprimer_ligne_listbox_Click()
Dim x As Integer
'Supprimer ligne selectionnée dans listbox
If Me.ListBox1.ListIndex = -1 And Me.ListBox2.ListIndex = -1 Then   ' << Si aucune sélection
        MsgBox "Veuillez selectionner une ligne d'une listbox ", _
               vbExclamation + vbOKOnly, "ATTENTION !"

        ' sinon, supprimer la sélection
Else
        If Me.ListBox1.ListIndex <> -1 Then
            Me.ListBox1.RemoveItem (Me.ListBox1.ListIndex)
            Me.ListBox1.ListIndex = -1         ' désélectionner après suppression
            Exit Sub

        End If
        If Me.ListBox2.ListIndex <> -1 Then

If Me.ListBox2.ListIndex = -1 Then Exit Sub

    If Me.ListBox1.ListCount > 0 Then
        For x = 0 To Me.ListBox1.ListCount - 1
            If Me.ListBox2.Column(1, Me.ListBox2.ListIndex) = Me.ListBox1.Column(1, x) Then
            Me.ListBox1.Column(0, x) = Me.ListBox1.Column(0, x) + 1
            Me.ListBox1.Column(2, x) = Me.ListBox2.List(Me.ListBox2.ListIndex, 2)

            Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = Me.ListBox2.List(Me.ListBox2.ListIndex, 0) - 1

'Message Cloture Suppression
If MsgBox("Avez-vous fini la suppression?", vbQuestion + vbYesNo, "ATTENTION !!!") = vbYesNo Then
End If
            On Error Resume Next
            If Me.ListBox2.Column(3, Me.ListBox2.ListIndex) - Me.ListBox2.Column(2, Me.ListBox2.ListIndex) >= 0 Then
                Me.ListBox1.Column(3, x) = CDbl(Me.ListBox1.Column(3, x)) + CDbl(Me.ListBox2.Column(2, Me.ListBox2.ListIndex))
                Me.ListBox2.Column(3, Me.ListBox2.ListIndex) = CDbl(Me.ListBox2.Column(3, Me.ListBox2.ListIndex)) - _
               CDbl(Me.ListBox2.Column(2, Me.ListBox2.ListIndex))
            End If
            On Error GoTo 0
            If Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = 0 Then Me.ListBox2.RemoveItem Me.ListBox2.ListIndex
            Exit Sub
            End If
         Next x

    Me.ListBox1.AddItem
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 0) = 1
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Me.ListBox2.Column(1, Me.ListBox2.ListIndex)
    Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = Me.ListBox2.List(Me.ListBox2.ListIndex, 0) - 1
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = "Suppression"
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = Me.TextBox12.Value
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = Me.TextBox13.Value
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = Me.ListBox2.Column(7, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = Liste_Serveurs_2.Caption

'Message Cloture Suppression
If MsgBox("Avez-vous fini la suppression?", vbQuestion + vbYesNo, "ATTENTION !!!") = vbYesNo Then
End If

   If Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = 0 Then Me.ListBox2.RemoveItem Me.ListBox2.ListIndex ' <<< ajout

Else
    Me.ListBox1.AddItem
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 0) = 1
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Me.ListBox2.Column(1, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = "Suppression"
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = Me.TextBox12.Value
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = Me.TextBox13.Value
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = Me.ListBox2.Column(7, Me.ListBox2.ListIndex)
    Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = Liste_Serveurs_2.Caption

    On Error Resume Next
    If Me.ListBox2.Column(3, Me.ListBox2.ListIndex) - Me.ListBox2.Column(2, Me.ListBox2.ListIndex) >= 0 Then
        Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = CDbl(Me.ListBox2.Column(2, Me.ListBox2.ListIndex))
        Me.ListBox2.Column(3, Me.ListBox2.ListIndex) = CDbl(Me.ListBox2.Column(3, Me.ListBox2.ListIndex)) - _
                Me.ListBox2.Column(2, Me.ListBox2.ListIndex)
    End If
    On Error GoTo 0
    Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = Me.ListBox2.List(Me.ListBox2.ListIndex, 0) - 1

    If Me.ListBox2.List(Me.ListBox2.ListIndex, 0) = 0 Then Me.ListBox2.RemoveItem Me.ListBox2.ListIndex ' <<< ajout

'Message Cloture Suppression
If MsgBox("Avez-vous fini la suppression?", vbQuestion + vbYesNo, "ATTENTION !!!") = vbYesNo Then
End If
End If

    Me.ListBox2.ListIndex = -1         ' désélectionner après suppression
    End If
End If

End Sub

A priori ça marche

J'aurais besoin de ton aide pour 2 truc, car je cale vraiment

1) j'aimerais que la ligne que ce place dans le textbox1 soit en rouge

2) Ce qui serais bien c'est que la quantité en première colonne de la listbox1 soit négatif et pas positif

En te remerciant de ton aide

Bonjour,

Je ne crois pas que ce soit possible de mettre en couleur le texte ou le fond d'une ligne d'une listbox ...

Pour ce faire, il faut changer la listbox contre une listview ...

La programmation est un peu différente ...

ric

Bonjour Ric,

Merci de ta réponse,

J'ai essaye de contourner la ligne rouge en faisant une forme conditionnelle.

Quand je le fais à la main, ça marche

Cependant, quand je le fais avec le bouton, ça marche pas

Tu crois qu'il y aurait moyen?

Merci

Rechercher des sujets similaires à "additionner click commandbutton textbox"