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

Macros et VBA Excel Discussion :

Addition de Textbox


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 113
    Par défaut Addition de Textbox
    Bonjour à tous, autre petit soucis, je n arrive pas à additionner 2 textbox voici mon code :

    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
    Private Sub TextBox31_AfterUpdate()
    TextBox31.Value = CDbl(TextBox32.Value) + CDbl(TextBox34.Value)
    End Sub
     
    Private Sub TextBox33_AfterUpdate()
    Me.TextBox33.Value = Format(CDbl(Me.TextBox33.Value), "# ##0.00 €")
    End Sub
     
    Private Sub TextBox31_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox31 = Format(Me.TextBox31, "# ##0.00 €")
    End Sub
     
     
    Private Sub TextBox32_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox32 = Format(Me.TextBox32, "# ##0.00 €")
    End Sub
     
     
    Private Sub TextBox33_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox33 = Format(Me.TextBox33, "# ##0.00 €")
    End Sub
     
    Private Sub TextBox34_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox34 = Format(Me.TextBox34, "# ##0.00 €")
    End Sub
     
     
    Private Sub TextBox37_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox37 = Format(Me.TextBox37, "# ##0.00 €")
    End Sub
    Merci

  2. #2
    Membre Expert Avatar de laetitia
    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    1 281
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : France

    Informations forums :
    Inscription : Décembre 2002
    Messages : 1 281
    Par défaut
    bonjour hawk91 le forum un exemple
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TextBox3 = (CDbl(TextBox1.Value) + CDbl(TextBox2.Value))
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TextBox3 = (Val(TextBox1.Value) + Val(TextBox2.Value))

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 113
    Par défaut
    Merci je vais tester, mon soucis est que le résultat ne s affiche pas automatiquement il faut taper un chiffre dans la cellule resultat, n importe lequel et la il s affiche

    Ta 1ere solution, je lutilise actuellement mais le chiffre ne s'affiche pas automatiquement.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    TextBox31.Value = CDbl(TextBox32.Value) + CDbl(TextBox34.Value)
    Et la 2eme ne change pas non plus, voila ce que j'ai mis actuellement

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Private Sub TextBox31_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox31 = Format(Me.TextBox31, "# ##0.00 €")
    TextBox31 = (Val(TextBox32.Value) + Val(TextBox34.Value))
    End Sub
    Merci

  4. #4
    Membre Expert Avatar de laetitia
    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    1 281
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : France

    Informations forums :
    Inscription : Décembre 2002
    Messages : 1 281
    Par défaut
    rebonjour le forum c est normal essai comme cela rajoute ce code dans change

    Option Explicit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Private Sub TextBox32_Change()
    On Error Resume Next
    TextBox31.Value = CDbl(TextBox32.Value) + CDbl(TextBox34.Value)
    End Sub
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Private Sub TextBox34_Change()
    On Error Resume Next
    TextBox31.Value = CDbl(TextBox32.Value) + CDbl(TextBox34.Value)
    End Sub

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    113
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 113
    Par défaut
    Humm mon code est un peu "brouillon", voici ce que j'ai puis je simplififer
    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
    Private Sub TextBox31_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
     
    TextBox31 = (Val(TextBox32.Value) + Val(TextBox34.Value))
    Me.TextBox31 = Format(Me.TextBox31, "# ##0.00 €")
    End Sub
     
    Private Sub TextBox32_Change()
    On Error Resume Next
    TextBox31.Value = CDbl(TextBox32.Value) + CDbl(TextBox34.Value)
    End Sub
     
     
    Private Sub TextBox32_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox32 = Format(Me.TextBox32, "# ##0.00 €")
    End Sub
     
     
    Private Sub TextBox33_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox33 = Format(Me.TextBox33, "# ##0.00 €")
    End Sub
     
    Private Sub TextBox34_Change()
    On Error Resume Next
    TextBox31.Value = CDbl(TextBox32.Value) + CDbl(TextBox34.Value)
    End Sub
     
     
    Private Sub TextBox34_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox34 = Format(Me.TextBox34, "# ##0.00 €")
    End Sub
     
     
    Private Sub TextBox37_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error Resume Next
    Me.TextBox37 = Format(Me.TextBox37, "# ##0.00 €")
    End Sub
    TextBox31 = Total32+34, TextBox32= Annexe, Tx34= Princi, Tx 33 montant val Tx 37 mont conf

  6. #6
    Membre Expert Avatar de laetitia
    Profil pro
    Inscrit en
    Décembre 2002
    Messages
    1 281
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : France

    Informations forums :
    Inscription : Décembre 2002
    Messages : 1 281
    Par défaut
    re on le met en haut dans le module mais si tu as aucune variable declaree c est pas la peine !!
    autrement en simplifiant ton code
    Option Explicit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Private Sub TextBox32_Change()
    On Error Resume Next
    TextBox31.Value = (CDbl(TextBox32.Value) + CDbl(TextBox34.Value))
    TextBox31 = Format(Me.TextBox31, "# ##0.00 €")
    End Sub
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Private Sub TextBox34_Change()
    On Error Resume Next
    TextBox31.Value = (CDbl(TextBox32.Value) + CDbl(TextBox34.Value))
    TextBox31 = Format(Me.TextBox31, "# ##0.00 €")
    End Sub
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Sub TextBox32_AfterUpdate()
    Me.TextBox32.Value = Format(CDbl(Me.TextBox32.Value), "# ##0.00 €")
    End Sub
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Sub TextBox34_AfterUpdate()
    Me.TextBox34.Value = Format(CDbl(Me.TextBox34.Value), "# ##0.00 €")
    End Sub

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

Discussions similaires

  1. [XL-2007] Renvoi d'addition de textbox dans une variable
    Par chrisaccess dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 13/01/2014, 13h57
  2. [AC-2010] Addition de textbox dans formulaire
    Par wisemanvsfatboy dans le forum IHM
    Réponses: 1
    Dernier message: 12/03/2011, 21h57
  3. Addition de TextBox ;-(
    Par thebossbest dans le forum C#
    Réponses: 5
    Dernier message: 01/08/2010, 16h50
  4. addition de textbox
    Par temjeh dans le forum Général JavaScript
    Réponses: 22
    Dernier message: 27/04/2007, 00h02
  5. Addition de textbox
    Par VARACH dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 01/02/2007, 08h31

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