Calcul du taux d'alcoolemie

Description

Calcul du taux d'alcoolemie en fonction du sexe et du poids du sujet et nombre d'heure de récupération

Source / Exemple :


' Conçu avec SharpDevelop 2.2.1
' Programmeur : DODICH
' Date : Décembre 2007
'
'
Imports System.Math
Imports System.DateTime
Imports System.Drawing.Color

Public Partial Class MainForm
	
	Dim ToolTip1 As New ToolTip
	Dim A, B, C, D, E As Decimal  'Variable alcool et total
	Dim K As Decimal 'Homme = 0.7 / Femme = 0.6
	Dim M As Integer  'Poids
	Dim T, R As Decimal  'T: Taux, R:  Récup
	
	Public Sub New()
		
		Me.InitializeComponent()
		'Affichage des infos sur les images
		ToolTip1.SetToolTip(Me.PictureBox1, "Calculer le taux d'alcoolémie")
		ToolTip1.SetToolTip(Me.PictureBox2, "Ajouter une bière")
		ToolTip1.SetToolTip(Me.PictureBox3, "Ajouter un verre de vin")
		ToolTip1.SetToolTip(Me.PictureBox4, "Ajouter un verre de vin")
		ToolTip1.SetToolTip(Me.PictureBox5, "Ajouter une dose d'alcool fort")
		ToolTip1.SetToolTip(Me.PictureBox6, "Ajouter une dose d'alcool doux")
		ToolTip1.SetToolTip(Me.PictureBox7, "Ajouter une dose d'alcool fort")
		ToolTip1.SetToolTip(Me.PictureBox10, "Afficher l'aide")
		K = 0.7
		M = 80
		
	End Sub
	
	Sub PictureBox1Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		Alcoolemie()
		
	End Sub
	
	Sub Alcoolemie
		
		On Error Resume Next
		
		E = A + B + C + D  'Total des consommation
		TextBox5.Text = E
		If radioButton1.Checked = True Then K = 0.7  'Homme
		If radioButton2.Checked = True Then K = 0.6  'Femme
		
		TextBox6.Text = (E * 0.8) / (K * M)  'Formule alcoolemie
		T = TextBox6.Text
		Label14.Text = Math.Round(T, 2)  'Arrondi 2 chiffres après la virgule
		
		R = Label14.Text - 0.5
		TextBox7.Text = R / 0.15 * 60  'Alcool à évacuer
		If TextBox7.Text < 0 Then TextBox7.Text = 0
		
		Dim Heure As String
        Heure = Int(TextBox7.Text / 60) & " heure(s) et " & TextBox7.Text Mod 60 & " minute(s)"
		Label17.Text = Heure  'Affichage du nombre d'heure(s) pour récupérer
		
		If TextBox7.Text < 0.5 Then
			'Affichage du texte en bleu ou en rouge
			Label14.ForeColor = System.Drawing.Color.SteelBlue
			Label15.ForeColor = System.Drawing.Color.SteelBlue
			Label17.Visible = False
		Else
			Label14.ForeColor = System.Drawing.Color.Firebrick
			Label15.ForeColor = System.Drawing.Color.Firebrick
			Label17.Visible = True
		End If
		
	End Sub
	
	Sub NumericUpDown4ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox1.Text = (numericUpDown4.Value * 250) * (numericUpDown7.Value / 100)
		A = TextBox1.Text  'valeur de 25cl de bière
		
	End Sub
	
	Sub NumericUpDown7ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox1.Text = (numericUpDown4.Value * 250) * (numericUpDown7.Value / 100)
		A = TextBox1.Text
		
	End Sub
	
	Sub NumericUpDown6ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox2.Text = (numericUpDown6.Value * 20) * (numericUpDown5.Value / 100)
		B = TextBox2.Text
		
	End Sub
	
	Sub NumericUpDown5ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox2.Text = (numericUpDown6.Value * 20) * (numericUpDown5.Value / 100)
		B = TextBox2.Text
		
	End Sub
	
	Sub NumericUpDown1ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		M = NumericUpDown1.Value
		
	End Sub
	
	Sub Timer1Tick(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		Label2.Text = Now.ToLongTimeString  'Affichage de l'heure
		
	End Sub
	
	Sub NumericUpDown9ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox3.Text = (numericUpDown9.Value * 100) * (numericUpDown8.Value / 100)
		C = TextBox3.Text
		
	End Sub
	
	Sub NumericUpDown8ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox3.Text = (numericUpDown9.Value * 100) * (numericUpDown8.Value / 100)
		C = TextBox3.Text
		
	End Sub
	
	Sub NumericUpDown11ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox4.Text = (numericUpDown11.Value * 60) * (numericUpDown10.Value / 100)
		D = TextBox4.Text
		
	End Sub
	
	Sub NumericUpDown10ValueChanged(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		TextBox4.Text = (numericUpDown11.Value * 60) * (numericUpDown10.Value / 100)
		D = TextBox4.Text
		
	End Sub
	
	Sub PictureBox2Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		numericUpDown4.Value = numericUpDown4.Value + 1
		
	End Sub
	
	Sub PictureBox3Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		numericUpDown9.Value = numericUpDown9.Value + 1
		
	End Sub
	
	Sub PictureBox4Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		numericUpDown9.Value = numericUpDown9.Value + 1
		
	End Sub
	
	Sub PictureBox5Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		numericUpDown6.Value = numericUpDown6.Value + 1
		
	End Sub
	
	Sub PictureBox7Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		numericUpDown6.Value = numericUpDown6.Value + 1
		
	End Sub
	
	Sub PictureBox6Click(ByVal sender As Object, ByVal e As EventArgs)
		
		On Error Resume Next
		
		numericUpDown11.Value = numericUpDown11.Value + 1
		
	End Sub
	
	Sub PictureBox10Click(ByVal sender As Object, ByVal e As EventArgs)
		
		PictureBox8.Visible = True  'Affichage de l'aide
		
	End Sub
	
	Sub PictureBox8Click(ByVal sender As Object, ByVal e As EventArgs)
		
		PictureBox8.Visible = False  'Masquer l'aide
		
	End Sub
	
End Class

Codes Sources

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.