Accueil > > > CALCULATRICE WINDOWS
CALCULATRICE WINDOWS
Information sur la source
Description
faites une interface de calculatrice windows standard et insérez ceci:
Source
- Private signe, retour As Byte
- Private N1, N2, mem As Single
- Private sepdec, zero As String
-
- Private Sub Form_Load()
- zero = "0"
- sepdec = ","
- txtAfficher.Text = "0,"
- retour = 1
- End Sub
-
- Private Sub cmdRetour_Click()
- If txtAfficher.Text <> "0" Then
- If Len(txtAfficher.Text) = 1 Then
- txtAfficher.Text = "0,"
- retour = 1
- Else
- txtAfficher.Text = Left(txtAfficher.Text, Len(txtAfficher.Text) - 1)
- End If
- End If
- End Sub
-
- Private Sub cmdSigne_Click()
- txtAfficher.Text = Not (Val(txtAfficher.Text)) - 1
- retour = 1
- End Sub
-
- Private Sub cmdVirgule_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + sepdec
- Else
- txtAfficher.Text = sepdec
- retour = 0
- End If
- End Sub
- ' Initialisation des commandes de 0 à 9
- Private Sub cmd0_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(0)
- Else
- txtAfficher.Text = CStr(0)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd1_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(1)
- Else
- txtAfficher.Text = CStr(1)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd2_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(2)
- Else
- txtAfficher.Text = CStr(2)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd3_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(3)
- Else
- txtAfficher.Text = CStr(3)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd4_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(4)
- Else
- txtAfficher.Text = CStr(4)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd5_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(5)
- Else
- txtAfficher.Text = CStr(5)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd6_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(6)
- Else
- txtAfficher.Text = CStr(6)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd7_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(7)
- Else
- txtAfficher.Text = CStr(7)
- retour = 0
- End If
- End Sub
-
- Private Sub cm8_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(8)
- Else
- txtAfficher.Text = CStr(8)
- retour = 0
- End If
- End Sub
-
- Private Sub cmd9_Click()
- If retour = 0 Then
- txtAfficher.Text = txtAfficher.Text + CStr(9)
- Else
- txtAfficher.Text = CStr(9)
- retour = 0
- End If
- End Sub
-
- Private Sub CmdC_Click()
- txtAfficher.Text = "0,"
- N1 = 0
- retour = 1
- End Sub
- 'Assignation des valeurs en entrée des opérands
- Private Sub cmdDivision_Click()
- N1 = Val(txtAfficher.Text)
- retour = 1
- signe = 1
- End Sub
-
- Private Sub cmdProduit_Click()
- N1 = Val(txtAfficher.Text)
- retour = 1
- signe = 2
- End Sub
-
- Private Sub cmdAddition_Click()
- N1 = Val(txtAfficher.Text)
- retour = 1
- signe = 3
- End Sub
-
- Private Sub cmdSoustraction_Click()
- N1 = Val(txtAfficher.Text)
- retour = 1
- signe = 4
- End Sub
- ' La sélection de l'opérand
- Private Sub cmdResultat_Click()
- N2 = Val(txtAfficher.Text)
- Dim virgule As Integer
- Select Case signe
- Case 1
- If Val(txtAfficher.Text) <> 0 Then
- N1 = N1 / N2
- Else
- N1 = "Erreur : nombre infini positif."
- End If
- Case 2
- N1 = N1 * N2
- virgule = InStr(CStr(N1), ",")
- If virgule = 0 Then
- zero = CStr(N1)
- txtAfficher.Text = zero & virgule
- Else
- zero = CStr(N1)
- txtAfficher.Text = zero
- End If
-
- Case 3
- N1 = N1 + N2
- virgule = InStr(CStr(N1), ",")
- If virgule = 0 Then
- zero = CStr(N1)
- txtAfficher.Text = zero & virgule
- Else
- zero = CStr(N1)
- txtAfficher.Text = zero
- End If
-
- Case 4
- N1 = N1 - N2
- virgule = InStr(CStr(N1), ",")
- If virgule = 0 Then
- zero = CStr(N1)
- txtAfficher.Text = zero & virgule
- Else
- zero = CStr(N1)
- txtAfficher.Text = zero
- End If
-
- End Select
- txtAfficher.Text = CStr(N1)
- retour = 1
- End Sub
- ' Fractions et racine carré
- Private Sub cmdSqrt_Click()
- txtAfficher.Text = Sqr(txtAfficher.Text)
- retour = 1
- End Sub
-
- Private Sub cmdPourcentage_Click()
- txtAfficher.Text = Val(txtAfficher.Text) / 100
- retour = 1
- End Sub
-
- Private Sub cmdFraction_Click()
-
- If Val(txtAfficher.Text) = 0 Then
- txtAfficher.Text = "Erreur : nombre infini positif."
- retour = 1
- Else
- If Val(txtAfficher.Text) <> 0 Then
- txtAfficher.Text = 1 / CStr(Val(txtAfficher.Text))
- retour = 1
- End If
- End If
- End Sub
- ' Gestion des touches mémoires
- Private Sub cmdMs_Click()
- mem = Val(txtAfficher.Text)
- txtMem.Text = "M"
- retour = 1
- End Sub
-
- Private Sub cmdMr_Click()
- txtAfficher.Text = mem
- retour = 1
- End Sub
-
- Private Sub cmdMc_Click()
- txtMem.Text = ""
- mem = 0
- retour = 1
- End Sub
-
- Private Sub cmdM_Click()
- mem = mem + Val(txtAfficher.Text)
- retour = 1
- End Sub
-
-
-
Private signe, retour As Byte
Private N1, N2, mem As Single
Private sepdec, zero As String
Private Sub Form_Load()
zero = "0"
sepdec = ","
txtAfficher.Text = "0,"
retour = 1
End Sub
Private Sub cmdRetour_Click()
If txtAfficher.Text <> "0" Then
If Len(txtAfficher.Text) = 1 Then
txtAfficher.Text = "0,"
retour = 1
Else
txtAfficher.Text = Left(txtAfficher.Text, Len(txtAfficher.Text) - 1)
End If
End If
End Sub
Private Sub cmdSigne_Click()
txtAfficher.Text = Not (Val(txtAfficher.Text)) - 1
retour = 1
End Sub
Private Sub cmdVirgule_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + sepdec
Else
txtAfficher.Text = sepdec
retour = 0
End If
End Sub
' Initialisation des commandes de 0 à 9
Private Sub cmd0_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(0)
Else
txtAfficher.Text = CStr(0)
retour = 0
End If
End Sub
Private Sub cmd1_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(1)
Else
txtAfficher.Text = CStr(1)
retour = 0
End If
End Sub
Private Sub cmd2_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(2)
Else
txtAfficher.Text = CStr(2)
retour = 0
End If
End Sub
Private Sub cmd3_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(3)
Else
txtAfficher.Text = CStr(3)
retour = 0
End If
End Sub
Private Sub cmd4_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(4)
Else
txtAfficher.Text = CStr(4)
retour = 0
End If
End Sub
Private Sub cmd5_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(5)
Else
txtAfficher.Text = CStr(5)
retour = 0
End If
End Sub
Private Sub cmd6_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(6)
Else
txtAfficher.Text = CStr(6)
retour = 0
End If
End Sub
Private Sub cmd7_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(7)
Else
txtAfficher.Text = CStr(7)
retour = 0
End If
End Sub
Private Sub cm8_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(8)
Else
txtAfficher.Text = CStr(8)
retour = 0
End If
End Sub
Private Sub cmd9_Click()
If retour = 0 Then
txtAfficher.Text = txtAfficher.Text + CStr(9)
Else
txtAfficher.Text = CStr(9)
retour = 0
End If
End Sub
Private Sub CmdC_Click()
txtAfficher.Text = "0,"
N1 = 0
retour = 1
End Sub
'Assignation des valeurs en entrée des opérands
Private Sub cmdDivision_Click()
N1 = Val(txtAfficher.Text)
retour = 1
signe = 1
End Sub
Private Sub cmdProduit_Click()
N1 = Val(txtAfficher.Text)
retour = 1
signe = 2
End Sub
Private Sub cmdAddition_Click()
N1 = Val(txtAfficher.Text)
retour = 1
signe = 3
End Sub
Private Sub cmdSoustraction_Click()
N1 = Val(txtAfficher.Text)
retour = 1
signe = 4
End Sub
' La sélection de l'opérand
Private Sub cmdResultat_Click()
N2 = Val(txtAfficher.Text)
Dim virgule As Integer
Select Case signe
Case 1
If Val(txtAfficher.Text) <> 0 Then
N1 = N1 / N2
Else
N1 = "Erreur : nombre infini positif."
End If
Case 2
N1 = N1 * N2
virgule = InStr(CStr(N1), ",")
If virgule = 0 Then
zero = CStr(N1)
txtAfficher.Text = zero & virgule
Else
zero = CStr(N1)
txtAfficher.Text = zero
End If
Case 3
N1 = N1 + N2
virgule = InStr(CStr(N1), ",")
If virgule = 0 Then
zero = CStr(N1)
txtAfficher.Text = zero & virgule
Else
zero = CStr(N1)
txtAfficher.Text = zero
End If
Case 4
N1 = N1 - N2
virgule = InStr(CStr(N1), ",")
If virgule = 0 Then
zero = CStr(N1)
txtAfficher.Text = zero & virgule
Else
zero = CStr(N1)
txtAfficher.Text = zero
End If
End Select
txtAfficher.Text = CStr(N1)
retour = 1
End Sub
' Fractions et racine carré
Private Sub cmdSqrt_Click()
txtAfficher.Text = Sqr(txtAfficher.Text)
retour = 1
End Sub
Private Sub cmdPourcentage_Click()
txtAfficher.Text = Val(txtAfficher.Text) / 100
retour = 1
End Sub
Private Sub cmdFraction_Click()
If Val(txtAfficher.Text) = 0 Then
txtAfficher.Text = "Erreur : nombre infini positif."
retour = 1
Else
If Val(txtAfficher.Text) <> 0 Then
txtAfficher.Text = 1 / CStr(Val(txtAfficher.Text))
retour = 1
End If
End If
End Sub
' Gestion des touches mémoires
Private Sub cmdMs_Click()
mem = Val(txtAfficher.Text)
txtMem.Text = "M"
retour = 1
End Sub
Private Sub cmdMr_Click()
txtAfficher.Text = mem
retour = 1
End Sub
Private Sub cmdMc_Click()
txtMem.Text = ""
mem = 0
retour = 1
End Sub
Private Sub cmdM_Click()
mem = mem + Val(txtAfficher.Text)
retour = 1
End Sub
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
calculatrice [ par yallah ]
Quelqu'un à t-il un script pour créer une calculatrice?Merci
calculatrice [ par petit prince ]
j'ai un problème avec la virgule et le zéro.je n'arrive pas à mettre de 0 après la virgule
Calculatrice : Additon ??? [ par Jeff ]
Bonjour, je recherche comment je doit faire pour pouvoir faire un addition.Je doit faire une calculatrice (comme celle de Windows). Merci à l'avance..
Comment utiliser la fonction KeyDown ??? [ par Jeff ]
Bonjour... Je me répète mais la réponse que j'ai eu ne fonctionne touours pas... J'avais écrit que je n'étais pas capable d'utiliser la fonction KeyDo
Appel calculatrice à partir OCX [ par jeanyves ]
Je souhaite appeler une calculatrice par un dblclick.Et ce, dans un OCX sur lequel je suis entrain de travailler (et de ramer)Avec la calculatrice Win
Creation d'un calculatrice financiere avec VB [ par bebepuff ]
Bonjour chers cracks,Je suis un etudiant de l'universite Laval en actuariat et notre cher professeur de Visual Basic nous a donne un travail consistan
ouvrir si pas ouvert [ par nerakcire ]
bonjours, je demande de l'aide car je cherche a réaliser un programme en VB6, qui réalise:l'ouverture d'un executable (exemple: calculatrice), que si
setfocus [ par chrisou31 ]
bonjour a tousje fais une petite calculatrice pour me roder peperelors du demarrage de l'appli, je fais un form.show suivi d'un form.setfocus dans le
Ouverture de la calculatrice depuis Word [ par congelator ]
Salut à tous,J'essaie d'attribuer, à une icone dans Word, l'ouverture de la calculatrice qui se trouve sous C:\WINDOWS\CALC.EXE Est-ce possible avec V
Aide pour la realisation d'une calculette [ par KaiserGringos ]
Bonjour !Je debute en programmation et on m'as demander de realiser une calculatrice convertisseur d'euro a l'ecole. Voila mon probleme, j'aimerais sa
|
Derniers Blogs
MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril SHAREPOINT 15 TECHNICAL PREVIEW MANAGED OBJECT MODEL SOFTWARE DEVELOPMENT KITSHAREPOINT 15 TECHNICAL PREVIEW MANAGED OBJECT MODEL SOFTWARE DEVELOPMENT KIT par Matthew
http://www.microsoft.com/download/en/details.aspx?id=28768&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+MicrosoftDownloadCenter+(Microsoft+Download+Center) ...
Cliquez pour lire la suite de l'article par Matthew
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|