Calcul de l'hypothénuse, d'un coté a partire de l'hypothénuse et verification si un triangle est rectangle

Contenu du snippet

voila ma première source: une calculateur de l'hypothénuse a partire des deux autres cotées, d'un coté a partire de l'hypoténuse et de l'autre coté et verification d'un triangle (rectangle ou pas)

si il y a des bugs ou des amiliorations possibles prevenez moi ;)

je pense bientot en créer d'autre mais en ce moment je n'ai pas trop le temps (je suis en 4eme lol)

Source / Exemple :


Sub choix()
Dim inputresult As String
inputresult = InputBox("calcul de l'hypothenuse: tapez h" & vbCrLf & "calcul d'un coté:tapez c" & vbCrLf & "verification si un triangle est rectangle tapez r", "choisissez une fonction")
If inputresult = "h" Then hypo
If inputresult = "c" Then coté
If inputresult = "r" Then rectangle
If inputresult = "a" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "b" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "d" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "e" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "f" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "g" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "i" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "j" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "k" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "l" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "m" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "n" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "o" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "p" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "q" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "s" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "t" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "u" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "v" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "w" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "y" Then MsgBox ("valeur invalide!"): Exit Sub
If inputresult = "z" Then MsgBox ("valeur invalide!"): Exit Sub
End Sub

Sub hypo()
Dim valA As Long
Dim valB As Long
Dim total As Double
Dim inputresult As String
inputresult = InputBox("premier coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valA = CLng(inputresult)
inputresult = InputBox("deuxiemme coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valB = CLng(inputresult)
total = CLng(Sqr(valA ^ 2 + valB ^ 2))
resultat = MsgBox("l'hypothenuse mesure" & total & " mm")
End Sub

Sub coté()
Dim valA As Long
Dim valB As Long
Dim total As Double
Dim inputresult As String
inputresult = InputBox("premier coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valA = CLng(inputresult)
inputresult = InputBox("deuxiemme coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valB = CLng(inputresult)
total = CLng(Sqr(valA ^ 2 - valB ^ 2))
resultat = MsgBox("l'hypothenuse mesure" & total & " mm")
End Sub
Sub rectangle()
Dim valA As Long
Dim valB As Long
Dim valC As Long
Dim total As Double
Dim inputresult As String
inputresult = InputBox("dimensions du plus grand coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valA = CLng(inputresult)
inputresult = InputBox("dimensions du segond coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valB = CLng(inputresult)
inputresult = InputBox("dimensions du troisiemme coté (en mm) :", "dimensions")
If Not IsNumeric(inputresult) Then MsgBox ("valeur invalide!"): Exit Sub
valC = CLng(inputresult)
total = CLng(Sqr(valB ^ 2 + valC ^ 2))
total = CLng(total)
If valA = total Then MsgBox ("le triangle est rectangle")
If valA < total Then MsgBox ("le triangle n'est pas rectangle")
If valA > total Then MsgBox ("le triangle n'est pas rectangle")
End Sub

Conclusion :


remerciments a M dias (mon prof de techno) pour m'avoir aidé a finalisé et corrigé cette source

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.