CMT400

ARITHMETIC LOGARITHM
Name

Matric Id

Mohamad Amir Aqmar Bin Mohamad
Najid

2015143903

Siti Soleha Binti Hamzah

2015143289

Julyle Binti Muhamad Sugandi

2015135319

Wan Nur Ariffa Binti Wan Bakree

2015115229

Anis Syuhada Binti Omar Hamdan

2015145285

1-open Excel .

2-press Alt+F11 .

-select Insert-user form .

4setting the properti es table .

textboxes. and us .insert commands.

Example the textbox .

Example the command .

.

To clear data in the To display field End Sub Exit Private Sub cmdBtnExit_Click() End End Sub Back '5.1) End Sub Square Private Sub cmdBtnSqr_Click() If txtRes <> 0 Then txtDisplay = txtRes txtRes = txtRes * txtRes calVal = "Square" End If End Sub . To go back one step. Private Sub cmdBtnBak_Click() If txtRes <> 0 And txtRes <> "" Then txtRes = Left(txtRes. Settings properties of the userform.6-writing the code Command Button Code Clear Private Sub cmdBtnclr_Click() txtRes = 0: txtDisplay = Empty '3. '4. Len(txtRes) .

Command Button Code Cube Private Sub cmdBtnCube_Click() If txtRes <> 0 Then txtDisplay = txtRes txtRes = txtRes * txtRes * txtRes calVal = "Cube" End If End Sub Divide '6. For divide symbol Private Sub cmdBtnDvd_Click() If txtRes <> 0 Then txtDisplay = txtRes txtRes = 0 calVal = "Divide" End If End Sub Multiplication ' 7. For multiplication symbol Private Sub cmdBtnMult_Click() If txtRes <> 0 Then txtDisplay = txtRes txtRes = 0 calVal = "Multiplication" End If End Sub .

SNum Case "Multiplication" txtRes = FNum * SNum Case "Divide" If SNum = 0 Then txtRes = "Cannot divide by Zero" Else txtRes = FNum / SNum End If Case Else End Select txtDisplay = Empty End If ErrOcccered: End Sub . Final Calculations Private Sub cmdBtnEql_Click() On Error GoTo ErrOcccered 'Dim txtRes As Long If txtDisplay = "Cannot divide by Zero" Then txtDisplay = Empty If txtRes <> "" And calVal <> "" Then FNum = Val(txtDisplay): SNum = Val(txtRes) Select Case calVal Case "Add" txtRes = FNum + SNum Case "Minus" txtRes = FNum .Command Button Equal Code '21.

Add Dot to the To display area Private Sub cmdBtnDot_Click() If txtRes <> 0 Then txtRes = txtRes + "." End Sub . For minus symbol Private Sub cmdBtnMns_Click() If txtRes <> 0 Then txtDisplay = txtRes txtRes = 0 calVal = "Minus" End If End Sub Dot '10.Command Button Code Add '9. For addition symbol Private Sub cmdBtnAdd_Click() If txtRes <> 0 Then txtDisplay = txtRes txtRes = 0 calVal = "Add" End If End Sub Minus '8.

6.7. 1.3.4.8. To display Number 0.9) '20.Command Button Code Number (0. Private Sub cmdBtn0_Click() txtRes = txtRes + cmdBtn0.Caption End Sub Concatenate Private Sub cmdCombine_Click() txtAnswer = txtDisplay + txtRes End Sub .5.2.

Private Sub txtRes_Change() If txtRes.TextLength > 10 Then MsgBox "Its Too long to calculate value.".Text = Left(txtRes.Text. vbInformation txtRes. 10) Exit Sub End If End Sub . To displaying message when exceeding more then 10 numbers on the To display area.Textboxes Coding Answer Private Sub txtAnswer_Change() End Sub Display Private Sub txtDisplay_Change() End Sub Res '2.

Assign Maximum length to diplay numbers Private Sub UserForm_Initialize() txtRes.MaxLength = 10 txtDisplay.User form Coding Userform '1.MaxLength = 10 End Sub .

Key in number to test the calculator .

THANK YOU .