
'----------------------------------------------------------------
' Hands-On 1-1
'----------------------------------------------------------------

Sub ShowMessage()
    MsgBox "This is a message box in VBA."
End Sub

Sub ShowMessage2(strMessage)
   MsgBox strMessage
End Sub

Sub ShowMessage3(strMessage, strUserName)
    MsgBox strUserName & ",  your message is: " & strMessage
End Sub

Function addTwoNumbers()
    Dim num1 As Integer
    Dim num2 As Integer
    
    num1 = 3
    num2 = 2
    addTwoNumbers = num1 + num2
End Function

Function addTwoNumbers2(num1 As Integer, num2 As Integer)
    addTwoNumbers2 = num1 + num2
End Function


'----------------------------------------------------------------
' Hands-On 1-2
' Statements to be entered in the Immediate Window
'----------------------------------------------------------------

ShowMessage2 "I'm learning VBA."
ShowMessage3 "Keep on learning.", "John"
Call ShowMessage3("Keep on learning.", "John")
?addTwoNumbers
?addTwoNumbers2(56,24)
msgBox("Total=" & addTwoNumbers2(34,80))


'----------------------------------------------------------------
' Hands-On 1-3
'----------------------------------------------------------------

Private Sub ContactName_GotFocus()
    Me.ContactName.BackColor = 65280
End Sub

Private Sub ContactName_LostFocus()
    Me.ContactName.BackColor = 13434879

   ' an alternative way to specify color
    'Me.ContactName.BackColor = RGB(0, 255,0) 
End Sub


'----------------------------------------------------------------
' Hands-On 1-4
' No code for this Hands-On. 
' Please follow the instructions in the book.
'----------------------------------------------------------------


