Advertisement
albusmw

Untitled

Apr 11th, 2020
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit On
  2. Option Strict On
  3.  
  4. Public Class Form1
  5.  
  6.     Private Sub BT_CALCUL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_CALCUL.Click
  7.         LBL_COUT.Visible = False
  8.         If Verification() Then
  9.             LBL_COUT.Text = "Le cout du voyage sera de " & Calcul(TXT_CONSOMMATION.Text, TXT_NBKM.Text, Me.TXT_PRIXESS.Text) & " €"
  10.             LBL_COUT.Visible = True
  11.         End If
  12.         LBL_ERR.Visible = Not LBL_COUT.Visible
  13.     End Sub
  14.  
  15.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
  16.         LBL_COUT.Visible = False
  17.         LBL_ERR.Visible = False
  18.     End Sub
  19.  
  20.     Function Verification() As Boolean
  21.         If Not IsNumeric(Me.TXT_CONSOMMATION.Text) Then Return False
  22.         If Not IsNumeric(Me.TXT_NBKM.Text) Then Return False
  23.         If Not IsNumeric(Me.TXT_PRIXESS.Text) Then Return False
  24.         Return True
  25.     End Function
  26.  
  27.     Function Calcul(ByVal Consommation As String, ByVal NbKm As String, ByVal PrixEss As String) As Double
  28.         Dim Cout As Double
  29.         Cout = ((Val(NbKm) / 100) * Val(Consommation)) * Val(PrixEss)
  30.         Return Cout
  31.     End Function
  32.  
  33.     Private Function GetVal(ByVal Text As String) As Double
  34.         Return Val(Text.Replace(",", "."))
  35.     End Function
  36.  
  37. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement