TO: Dr Jennifer Glenn
FROM: Ali Almskof
SUBJECT: ENGR 1412 (ASSIGNMENT 3)
DISCUSSION AND VALIDATION DATE: 03 March 2018
Dr Jennifer Glenn,
This is my memo for my assignment 3. I hope our various user forms are easy to navigate through.
Purpose: I am submitting my Excel macro-enabled assignment that was constructed to complete the requirements for assignment 3.
Solution/Approach: I started off with designing the buttons in the format that worked with the template sheet as well as what we thought would be most efficient for a user. We then worked from each command button and designating the appropriate coding for each. Working through each button and it’s coding it was simple enough to go through each different user form in creating the calculator and its functions.
Observations: Both my partner and I saw that the assignment was rather lengthy and time consuming. With this being said i started early on the task and was able to work on it through the week, stress free.
Validation: In order to check our work, I checked my results with the sample template that was posted.
The following are the procedures/codes for all the tasks for your perusal:
Task 1
Temperature conversion
Sub temp_controls()
Cells(11, 2).value = "TEMPARATURE"
Sheets("Task #1").conv_fah_btn.Visible = True
Sheets("Task #1").conv_celsius_btn.Visible = True
Sheets("Task #1").conv_fah_btn.Enabled = True
Sheets("Task #1").conv_celsius_btn.Enabled = True
End Sub
Private Sub conv_celsius_btn_Click()
conv_fah_btn.Enabled = False
Dim temparature, t_celsius, t_fh As Single
temparature = Cells(11, 6)
t_celsius = (temparature - 32) / 1.8
Cells(19, 6) = t_celsius
Cells(19, 2) = "Convertion From Fahreinheit To Celsius ="
End Sub
Private Sub conv_fah_btn_Click()
conv_celsius_btn.Enabled = False
Dim temparature, t_celsius, t_fh As Single
temparature = Cells(11, 6)
t_fh = (temparature * 1.8) + 32
Cells(19, 6) = t_fh
Cells(19, 2) = "Convertion From Celcius To Fahreinheit ="
End Sub
Interest Calculator
Sub interest_controls()
Sheets("Task #1").interest_btn.Visible = True
Cells(11, 2).value = "PRINCIPAL(P)"
Cells(13, 2).value = "NUMBER OF PERIODS(N)"
Cells(15, 2).value = "RATE OF INTEREST(R)"
End Sub
Private Sub interest_btn_Click()
Cells(19, 2).value = "SIMPLE INTEREST IS"
Dim principal, period, rate, interest As Single
principal = Cells(11, 6)
period = Cells(13, 6)
rate = Cells(15, 6)
interest = (principal * period * rate) / 100
Cells(19, 6) = interest
End Sub
BMI CALCULATOR
Sub bmi_controls()
Sheets("Task #1").bmi_btn.Visible = True
Cells(11, 2).value = "WEIGHT(KG)"
Cells(13, 2).value = "HEIGHT(M)"
End Sub
Private Sub bmi_btn_Click()
Cells(19, 2).value = "BMI IS"
Cells(21, 2).value = "COMMENT"
Dim weight, height, bmi, x As Single
weight = Cells(11, 6)
height = Cells(13, 6)
bmi = (weight) / height ^ 2
Cells(19, 6) = Round(bmi, 1)
If bmi < 19 Then
Cells(21, 6) = "Under weight"
ElseIf bmi >= 19 And bmi < 25 Then
Cells(21, 6) = "Normal"
ElseIf bmi >= 25 And bmi < 30 Then
Cells(21, 6) = "Overweight"
ElseIf bmi >= 30 And bmi < 40 Then
Cells(21, 6) = "Obese"
Else
Cells(21, 6) = "Extremely Obese"
End If
End Sub
Clear Cells
Sub clear_cells()
Sheets("Task #1").bmi_btn.Visible = False
Sheets("Task #1").interest_btn.Visible = False
Sheets("Task #1").conv_fah_btn.Visible = False
Sheets("Task #1").conv_celsius_btn.Visible = False
Cells(11, 2).MergeArea.ClearContents
Cells(13, 2).MergeArea.ClearContents
Cells(19, 2).MergeArea.ClearContents
Cells(21, 2).MergeArea.ClearContents
Cells(11, 6).MergeArea.ClearContents
Cells(13, 6).MergeArea.ClearContents
Cells(19, 6).MergeArea.ClearContents
Cells(21, 6).MergeArea.ClearContents
Cells(15, 2).MergeArea.ClearContents
Cells(15, 6).MergeArea.ClearContents
End Sub
TASK 2- PALINDROME
Private Sub pal_btn_Click()
If Cells(7, 3) = StrReverse(Cells(7, 3)) Then
Cells(7, 6) = "YES"
Else
Cells(7, 6) = "NO"
End If
End Sub
TASK 3
Private Sub run_btn_Click()
Dim first_num, second_num, x As Integer
first_num = Cells(7, 16)
second_num = Cells(10, 16)
If IsNumeric(first_num & second_num) Then
x = (first_num * second_num)
Cells(13, 16) = x
ElseIf Not IsNumeric(first_num & second_num) Then
MsgBox ("Enter integers only!")
ElseIf first_num > 1 Then
x = (first_num / second_num)
Cells(13, 16) = x
End If
End Sub