ម៉ាស៊ីនគិតលេខ​​ Access 2007

1កូដ Microsoft Access 2007

Option Compare Database

Option Explicit
Dim i As Integer
Dim Var1 As String
Dim Var2 As String
Dim Calculate As Boolean
Dim Dot As Boolean
Dim Result As Double
Dim A As Double
Dim B As Double
Private Sub cmd0_Click()
If Calculate = False Then
Var1 = Var1 & 0
Me.txtResult = Var1
Else
Var2 = Var2 & 0
Me.txtResult = Var2
End If
End Sub

Private Sub cmd1x_Click()
i = 5

End Sub

Private Sub cmd2_Click()
If Calculate = False Then
Var1 = Var1 & 2
Me.txtResult = Var1
Else
Var2 = Var2 & 2
Me.txtResult = Var2
End If
End Sub

Private Sub cmd3_Click()
If Calculate = False Then
Var1 = Var1 & 3
Me.txtResult = Var1
Else
Var2 = Var2 & 3
Me.txtResult = Var2
End If
End Sub

Private Sub cmd4_Click()
If Calculate = False Then
Var1 = Var1 & 4
Me.txtResult = Var1
Else
Var2 = Var2 & 4
Me.txtResult = Var2
End If
End Sub

Private Sub cmd5_Click()
If Calculate = False Then
Var1 = Var1 & 5
Me.txtResult = Var1
Else
Var2 = Var2 & 5
Me.txtResult = Var2
End If
End Sub

Private Sub cmd6_Click()
If Calculate = False Then
Var1 = Var1 & 6
Me.txtResult = Var1
Else
Var2 = Var2 & 6
Me.txtResult = Var2
End If
End Sub

Private Sub cmd7_Click()
If Calculate = False Then
Var1 = Var1 & 7
Me.txtResult = Var1
Else
Var2 = Var2 & 7
Me.txtResult = Var2
End If
End Sub

Private Sub cmd8_Click()
If Calculate = False Then
Var1 = Var1 & 8
Me.txtResult = Var1
Else
Var2 = Var2 & 8
Me.txtResult = Var2
End If
End Sub

Private Sub cmd9_Click()
If Calculate = False Then
Var1 = Var1 & 9
Me.txtResult = Var1
Else
Var2 = Var2 & 9
Me.txtResult = Var2
End If
End Sub

Private Sub cmdAdd_Click()
Calculate = True
i = 1
A = Me.txtResult
End Sub

Private Sub cmdClear_Click()
txtResult = “”
Var1 = “”
Var2 = “”
A = 0
B = 0
End Sub

Private Sub cmdDiv_Click()
Calculate = True
i = 4
A = Me.txtResult
End Sub

Private Sub cmddot_Click()

If Calculate = False Then
Var1 = Var1 & “.”
Else
Var2 = Var2 & “.”
End If
End Sub
Private Sub CalculateResult(TT As TextBox)
B = Me.TT
If i = 1 Then
Result = A + B
ElseIf i = 2 Then
Result = A – B
ElseIf i = 3 Then
Result = A * B
ElseIf i = 4 Then
Result = A / B
ElseIf i = 5 Then
Result = 1 / Me.txtResult
ElseIf i = 6 Then
Result = A Mod B
End If
TT = Result
End Sub
Private Sub cmdEqual_Click()
B = 0
B = Me.txtResult
If i = 1 Then
Result = A + B
ElseIf i = 2 Then
Result = A – B
ElseIf i = 3 Then
Result = A * B
ElseIf i = 4 Then
Result = A / B
ElseIf i = 5 Then
Result = 1 / Me.txtResult
ElseIf i = 6 Then
Result = A Mod B
End If
A = 0
B = 0
Var1 = “”
Var2 = “”
Me.txtResult = Result
Calculate = False
End Sub

Private Sub cmdMod_Click()
Calculate = True
i = 6
A = Me.txtResult
End Sub

Private Sub cmdMulti_Click()
Calculate = True
i = 3
A = Me.txtResult
End Sub

Private Sub cmdNum1_Click()
If Calculate = False Then
Var1 = Var1 & 1
Me.txtResult = Var1
Else
Var2 = Var2 & 1
Me.txtResult = Var2
End If
End Sub

Private Sub cmdOff_Click()
DoCmd.Close
End Sub

Private Sub cmdSub_Click()
Calculate = True
i = 2
A = Me.txtResult
End Sub

Private Sub Form_Load()
Me.txtResult = “”
Var1 = “”
Var2 = “”

End Sub