FreshCoder
Registered User.
- Local time
- Today, 02:29
- Joined
- Sep 22, 2018
- Messages
- 33
Hi!
Can someone tell me if the layout of this code is ok?
Can someone tell me if the layout of this code is ok?
Code:
Option Compare Database
Option Explicit
Private M As Double
Dim i As Double
Dim v1 As Double, v2 As Double, v As Double
Dim op As String
Private Sub Com0_Click()
txtDisplay = txtDisplay & "0"
End Sub
Private Sub Com1_Click()
txtDisplay = txtDisplay & "1"
End Sub
Private Sub Com2_Click()
txtDisplay = txtDisplay & "2"
End Sub
Private Sub Com3_Click()
txtDisplay = txtDisplay & "3"
End Sub
Private Sub Com4_Click()
txtDisplay = txtDisplay & "4"
End Sub
Private Sub Com5_Click()
txtDisplay = txtDisplay & "5"
End Sub
Private Sub Com6_Click()
txtDisplay = txtDisplay & "6"
End Sub
Private Sub Com7_Click()
txtDisplay = txtDisplay & "7"
End Sub
Private Sub Com8_Click()
txtDisplay = txtDisplay & "8"
End Sub
Private Sub Com9_Click()
txtDisplay = txtDisplay & "9"
End Sub
Private Sub comMRC_Click()
txtDisplay = M
M = 0
End Sub
Private Sub ComDesimal_Click()
txtDisplay = txtDisplay & ","
End Sub
Private Sub ComPluss_Click()
txtDisplay = txtDisplay & "+"
End Sub
Private Sub ComMinus_Click()
txtDisplay = txtDisplay & "-"
End Sub
Private Sub ComMult_Click()
txtDisplay = txtDisplay & "*"
End Sub
Private Sub ComDiv_Click()
txtDisplay = txtDisplay & "/"
End Sub
Private Sub ComClear_Click()
txtDisplay = ""
End Sub
Private Sub ComMpluss_Click()
If txtDisplay <> 0 Then
M = M + txtDisplay
End If
End Sub
Private Sub ComMminus_Click()
If txtDisplay <> 0 Then
M = M - txtDisplay
End If
End Sub
Private Sub ComLik_Click()
'Oppsett for et uttrykk i txtDisplay med maks en operatør
For i = 1 To Len(txtDisplay)
op = Mid(txtDisplay, i, 1)
If (op < "0" Or op > "9") And op <> "," Then
Exit For
End If
Next i
v1 = Left(txtDisplay, i - 1)
v2 = Right(txtDisplay, Len(txtDisplay) - i)
If op = "+" Then
v = v1 + v2
ElseIf op = "-" Then
v = v1 - v2
ElseIf op = "*" Then
v = v1 * v2
ElseIf op = "/" Then
v = v1 / v2
End If
txtDisplay = v
End Sub