ASC454: ACTUARIAL
PROGRAMMING
USER INTERFACE
Ms Sarah Nadirah Mohd Johari, 2021
STEPS TO WRITE CODING IN VBA MICROSOFT
EXCEL
1. Opening syntax
Sub NameOfYourProgram()
2. Determine and declare the variables/inputs&outputs
Dim NameOfYourVariables/Inputs/Outputs As DataType
3. Insert/Store input
4. Write the process/method syntax
5. Display the output
6. Ending syntax
End Sub
Ms Sarah Nadirah Mohd Johari, 2021
STEPS TO WRITE CODING USER DEFINED
FUNCTION IN MODULE
1. Opening syntax
Function NameOfYourProgram ( NameOfYourVariables/Inputs As
DataType)
**Note: must code in correct order of your input in Ms Excel spreadsheet
2. Determine and declare the variables/inputs&outputs
Dim NameOfYourVariables/Process/Outputs As DataType
3. Write the process/method syntax
*Note: Last process that display the output, the name of this process must
share the same name as the NameOfYourProgram
4. Ending syntax
End Function
Ms Sarah Nadirah Mohd Johari, 2021
USER INTERFACE
• Other name: user form
• Can be used to create grocery lists, address books, rosters, todo lists and
etc
• Increasing efficiency; eliminating redundancy and restricting entries to
only the available options.
• To create this, requires some programming.
• UserForm ensures uniformity and that required fields contain text.
• Allows a seamless data entry process and eliminates the need to navigate
cells in the spreadsheet, saving time.
Ms Sarah Nadirah Mohd Johari, 2021
USER INTERFACE
• Guides the user with the information that is wanted and limits the type
of data entered to preset options.
• Ensures the data is entered in the correct place and allows control over
what format, style, and content are allowed, creating uniformity.
Ms Sarah Nadirah Mohd Johari, 2021
HOW TO CREATE USER INTERFACE
1) Open the Visual Basic Editor (alt + f11)
2) Click Insert > UserForm
3) New pop up window appear
(UserForm1 (UserForm))
Ms Sarah Nadirah Mohd Johari, 2021
HOW TO CREATE USER INTERFACE
If the toolbox does not
appear, click here
Ms Sarah Nadirah Mohd Johari, 2021
EXAMPLE OF USER INTERFACE
1) Label box
2) Text box 1 2
3) Command Button
3
Ms Sarah Nadirah Mohd Johari, 2021
USER INTERFACE SYNTAX
1) Label box – [Link]
2) Text box – [Link]
3) Command Button – follow the steps that you have learnt.
Ms Sarah Nadirah Mohd Johari, 2021
STEPS TO WRITE CODING IN USER INTERFACE
Private Sub CommandButton1_Click()
Dim name As String
name = [Link]
MsgBox ("Welcome " & name)
End Sub
Ms Sarah Nadirah Mohd Johari, 2021
EXERCISE
Ms Sarah Nadirah Mohd Johari, 2021
EXERCISE
Ms Sarah Nadirah Mohd Johari, 2021