• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. VBA 101: The Basics of VBA > Passing Parameters and Returning Values...

Passing Parameters and Returning Values: An Introduction

Both subroutines and functions can receive arguments (parameters), but only functions can return values. The following subroutine receives two parameters, txtFirst and txtLast. It then displays a message box with the first character of each of the parameters that was passed.

Private Sub cmdSendNames_Click()
  Call Initials(Me!txtFirstName, Me!txtLastName)
End Sub

Sub Initials(strFirst As String, strLast As String)
  MsgBox "Your Initials Are: " & Left$(strFirst, 1) _
   & Left$(strLast, 1)
End Sub


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint