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

Windows Forms Discussion :

Calculatrice en C#


Sujet :

Windows Forms

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2014
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2014
    Messages : 14
    Par défaut Calculatrice en C#
    Bonjour,

    J'ai quelques question par rapport à une calculatrice C#.

    J'ai un blocage sur la façon de coder les touche «CE», «MC», «MR», «MS», «M+» et «M-» ..
    Si vous pouvez m'aider ça serais super !

    PS : J'ai mon programme en DL si vous voulez ^^'
    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
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
     
    namespace Calculatrice
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
     
            }
            string bufferChiffre1;
            string bufferChiffre2;
            double reponse;
            double bufferChiffreString;
            string operateur;
            double convertChiffre1;
            double convertChiffre2;
            double memoireMPlus = 0;
     
            private void button11_Click(object sender, EventArgs e)
            {
                textBox1.Text += 7;
            }
     
            private void button12_Click(object sender, EventArgs e)
            {
                textBox1.Text += 8;
            }
     
            private void button13_Click(object sender, EventArgs e)
            {
                textBox1.Text += 9;
            }
     
            private void button14_Click(object sender, EventArgs e)
            {
                textBox1.Text += 4;
            }
     
            private void button15_Click(object sender, EventArgs e)
            {
                textBox1.Text += 5;
            }
     
            private void button16_Click(object sender, EventArgs e)
            {
                textBox1.Text += 6;
            }
     
            private void button17_Click(object sender, EventArgs e)
            {
                textBox1.Text += 1;
            }
     
            private void button18_Click(object sender, EventArgs e)
            {
                textBox1.Text += 2;
            }
     
            private void button19_Click(object sender, EventArgs e)
            {
                textBox1.Text += 3;
            }
     
            private void button20_Click(object sender, EventArgs e)
            {
                textBox1.Text += 0;
            }
     
            private void button21_Click(object sender, EventArgs e)
            {
                textBox1.Text += ", ";
            }
     
            private void button25_Click(object sender, EventArgs e)
            {
                bufferChiffre1 = textBox1.Text;
                textBox2.Text = bufferChiffre1;
                operateur = "+";
                textBox1.Text += " + ";
                textBox2.Text += " + ";
                textBox1.Clear();
            }
     
            private void button22_Click(object sender, EventArgs e)
            {
     
                bufferChiffre1 = textBox1.Text;
                textBox2.Text = bufferChiffre1;
                operateur = "/";
                textBox1.Text += " / ";
                textBox2.Text += " / ";
                textBox1.Clear();
            }
     
            private void button23_Click(object sender, EventArgs e)
            {
                bufferChiffre1 = textBox1.Text;
                textBox2.Text = bufferChiffre1;
                operateur = "*";
                textBox1.Text += " * ";
                textBox2.Text += " * ";
                textBox1.Clear();
            }
     
            private void button24_Click(object sender, EventArgs e)
            {
                bufferChiffre1 = textBox1.Text;
                textBox2.Text = bufferChiffre1;
                operateur = "-";
                textBox1.Text += " - ";
                textBox2.Text += " - ";
                textBox1.Clear();
            }
            private void button28_Click(object sender, EventArgs e)
            {
                bufferChiffre1 = textBox1.Text;
                textBox2.Text = bufferChiffre1;
                operateur = "%";
                textBox1.Text += " % ";
                textBox2.Text += " % ";
                textBox1.Clear();
            }
            private void button27_Click(object sender, EventArgs e)
            {
                operateur = "1/x";
     
                textBox2.Text = "reciproc(" + textBox1.Text + ")";
     
            }
            private void button9_Click(object sender, EventArgs e)
            {
                operateur = "±";
                try
                {
                    reponse = Convert.ToDouble(textBox1.Text);
                    reponse = reponse - (2 * reponse);
                    bufferChiffre1 = Convert.ToString(reponse);
                    textBox1.Text = bufferChiffre1;
                }
                catch (FormatException ex)
                {
                    MessageBox.Show("Veuillez indiquez un chiffre avant", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
     
            }
            private void button10_Click(object sender, EventArgs e)
            {
                operateur = "√";
                try
                {
                    bufferChiffre1 = textBox1.Text;
                    bufferChiffreString = Convert.ToDouble(bufferChiffre1);
                    reponse = Math.Sqrt(Convert.ToDouble(textBox1.Text));
                    textBox2.Text = "√" + textBox1.Text;
                    textBox1.Clear();
                }
                catch (FormatException ex)
                {
                    MessageBox.Show("Veuillez indiquez un chiffre avant", "Information",MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
     
     
            }
            private void button26_Click(object sender, EventArgs e)
            {
                if (operateur == "+")
                {
                    bufferChiffre2 = textBox1.Text;
                    textBox2.Text += bufferChiffre2 + " = ";
                    convertChiffre1 = Convert.ToDouble(bufferChiffre1);
                    convertChiffre2 = Convert.ToDouble(bufferChiffre2);
                    reponse = convertChiffre1 + convertChiffre2;
                    textBox2.Text += reponse;
                    textBox1.Text = Convert.ToString(reponse);                
                    convertChiffre1 = reponse;
     
                }
                else if (operateur == "√")
                {
                    textBox2.Text = "√" + bufferChiffre1 + " = " + reponse;
                    textBox1.Clear();
     
                }
                else if (operateur == "1/x")
                {
                    try
                    {
                        reponse = Convert.ToDouble(textBox1.Text);
                        reponse = 1 / reponse;
                        textBox2.Text = "reciproc(" + textBox1.Text + ") = " + reponse;
     
                    }
                    catch (FormatException ex)
                    {
                        MessageBox.Show("Avant de faire égale, entrez un calcul", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else if (operateur == "*")
                {
                    bufferChiffre2 = textBox1.Text;
                    textBox2.Text += bufferChiffre2 + " = ";
                    convertChiffre1 = Convert.ToDouble(bufferChiffre1);
                    convertChiffre2 = Convert.ToDouble(bufferChiffre2);
                    reponse = convertChiffre1 * convertChiffre2;
                    textBox2.Text += reponse;
                    textBox1.Text = Convert.ToString(reponse);
                    convertChiffre1 = reponse;
     
                }
                else if (operateur == "/")
                {
                    bufferChiffre2 = textBox1.Text;
                    textBox2.Text += bufferChiffre2 + " = ";
                    convertChiffre1 = Convert.ToDouble(bufferChiffre1);
                    convertChiffre2 = Convert.ToDouble(bufferChiffre2);
     
     
                }
                else if (operateur == "%")
                {
                    bufferChiffre2 = textBox1.Text;
                    textBox2.Text += bufferChiffre2 + " = ";
                    convertChiffre1 = Convert.ToDouble(bufferChiffre1);
                    convertChiffre2 = Convert.ToDouble(bufferChiffre2);
                    reponse = convertChiffre1 % convertChiffre2;
                    textBox2.Text += reponse;
                    textBox1.Text = Convert.ToString(reponse);
                    convertChiffre1 = reponse;
     
                }
     
                else if (operateur == "-")
                {
                    bufferChiffre2 = textBox1.Text;
                    textBox2.Text += bufferChiffre2 + " = ";
                    convertChiffre1 = Convert.ToDouble(bufferChiffre1);
                    convertChiffre2 = Convert.ToDouble(bufferChiffre2);
                    reponse = convertChiffre1 - convertChiffre2;
                    textBox2.Text += reponse;
                    textBox1.Text = Convert.ToString(reponse);
                    convertChiffre1 = reponse;
     
                }
     
            }
     
            private void button8_Click(object sender, EventArgs e)
            {
                textBox1.Clear();
                textBox2.Clear();
            }
     
            private void button7_Click(object sender, EventArgs e)
            {
     
            }
        }
    }
    Nom : Capture.PNG
Affichages : 6539
Taille : 10,0 Ko
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. Aide à la réalisation d'une calculatrice en C
    Par Premium dans le forum Algorithmes et structures de données
    Réponses: 8
    Dernier message: 17/11/2005, 16h52
  2. [Calculatrice TI82] Réaliser un jeu
    Par Zenol dans le forum Algorithmes et structures de données
    Réponses: 14
    Dernier message: 07/11/2005, 18h40
  3. calculatrice operations >a 1 chiffre
    Par xtaze dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 16/10/2005, 19h33
  4. [Comparaison] : Capacités des calculatrices/ordinateurs
    Par Évariste Galois dans le forum Algorithmes et structures de données
    Réponses: 12
    Dernier message: 02/08/2005, 16h06
  5. [AWT] Demande Explications prog calculatrice
    Par smag dans le forum Débuter
    Réponses: 3
    Dernier message: 07/07/2005, 16h06

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