Case 0 To 16.5 etc ...
imc.Text = (Math.Round(sPoids / (sTaille * sTaille), 1)).ToString
Private Sub calculimc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculimc.Click Dim sPoids As Single Dim sTaille As Single Dim sImc As Single ........ sImc=(Math.Round(sPoids / (sTaille * sTaille), 1)) 'Ici on travaille sur des nombres et on conserve le résultat en nombre imc.Text = sImc.ToString 'Ici on convertie le résultat en texte parce qu'on l'affiche mais on le conserve sous forme de nombre aussi If sImc < 16.5 Then 'Ici puiqu'on continue les calculs, on travaille toujours sur le nombre lui-même et pas sa représentation textuelle ........ If sImc > 40 Then labelimc.Text = "Obésité morbide ou massive" labelimc.BackColor = Color.Red End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub calculimc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculimc.Click Dim sPoids As Single Dim sTaille As Single If Not (IsNumeric(taille.Text)) Then MsgBox("Entrez une valeur numérique pour la taille") Exit Sub End If If Not (IsNumeric(poids.Text)) Then MsgBox("Entrez une valeur numérique pour le poids") Exit Sub End If sTaille = CType(taille.Text, Single) / 100 sPoids = CType(poids.Text, Single) If sTaille < 0.5 Or sTaille > 2.5 Then MsgBox("Entrez une taille valide") Exit Sub End If If sPoids < 20 Or sPoids > 500 Then MsgBox("Entrez un poids valide") Exit Sub End If imc.Text = (Math.Round(sPoids / (sTaille * sTaille), 1)).ToString If imc.Text < 16.5 Then labelimc.Text = ("Dénutrition ou famine") labelimc.BackColor = Color.Red End If If imc.Text < 18.5 Then labelimc.Text = "Maigreur" labelimc.BackColor = Color.Yellow End If If imc.Text < 25 Then labelimc.Text = "Corpulence normale" labelimc.BackColor = Color.White End If If imc.Text < 30 Then labelimc.Text = "Surpoids" labelimc.BackColor = Color.Yellow End If If imc.Text < 35 Then labelimc.Text = "Obésité modérée" labelimc.BackColor = Color.Chocolate End If If imc.Text < 40 Then labelimc.Text = "Obésité sévère" labelimc.BackColor = Color.OrangeRed End If If imc.Text > 40 Then labelimc.Text = "Obésité morbide ou massive" labelimc.BackColor = Color.Red End If End Sub
imc.Text = (Math.Round(sPoids / (sTaille * sTaille), 1)).ToString If imc.Text < 16.5 Then labelimc.Text = ("Dénutrition ou famine") labelimc.BackColor = Color.Red ElseIf imc.Text < 18.5 Then labelimc.Text = "Maigreur" labelimc.BackColor = Color.Yellow ElseIf imc.Text < 25 Then labelimc.Text = "Corpulence normale" labelimc.BackColor = Color.White ElseIf imc.Text < 30 Then labelimc.Text = "Surpoids" labelimc.BackColor = Color.Yellow ElseIf imc.Text < 35 Then labelimc.Text = "Obésité modérée" labelimc.BackColor = Color.Chocolate ElseIf imc.Text < 40 Then labelimc.Text = "Obésité sévère" labelimc.BackColor = Color.OrangeRed ElseIf imc.Text > 40 Then labelimc.Text = "Obésité morbide ou massive" labelimc.BackColor = Color.Red End If End Sub
imc.Text = (Math.Round(sPoids / (sTaille * sTaille), 1)).ToString .... If imc.Text < 16.5...