1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| Module Module2
Sub Main()
Do
Dim ValeurEntree As String = ""
Dim ValeurEntree1 As String = ""
Dim resultat As String = String.Empty
Dim nbre1 As Double = 0
Dim nbre2 As Double = 0
Dim tab(5) As String
Dim i As Integer
ValeurEntree = Console.ReadLine()
For i = 0 To tab.Length - 1
tab(i) = ValeurEntree
Next
For i = 0 To tab.Length - 1
resultat = eval(ValeurEntree, "")
tab(4) = "=" & resultat.ToString.Replace(",", ".")
Next
'Console.Write("=" & resultat.ToString.Replace(",", "."))
Console.Write(tab(4))
Loop
End Sub
Public Function eval(ByVal exp As String, ByVal op As String) As String
Dim tabOp(5) As String '= {"+", "-", "/", "*"}
tabOp(0) = "+"
tabOp(1) = "-"
tabOp(2) = "/"
tabOp(3) = "*"
tabOp(4) = "exit"
Dim i As Integer
Dim exp1 As String = ""
Dim exp2 As String = ""
If op.Length = 0 Then
For i = 0 To 4
If exp.Contains(tabOp(i)) Then
op = tabOp(i)
exp1 = exp.Split(op).GetValue(0).ToString.Replace(".", ",")
exp2 = exp.Split(op).GetValue(1).ToString.Replace(".", ",")
End If
Next
End If
Select Case op.ToLower
Case "+"
Return CDbl(exp1) + CDbl(exp2)
Case "-"
Return CDbl(exp1) - CDbl(exp2)
Case "*"
Return CDbl(exp1) * CDbl(exp2)
Case "/"
Return CDbl(exp1) / CDbl(exp2)
Case "exit"
Console.WriteLine("MERCI D'AVOIR UTLISE CALCULATRICE")
Console.WriteLine()
Console.Read()
Return "e"
End Select
End Function
End Module |
Partager