Procedure arguments have the Variant data type by default. However, you can declare other data types for arguments, using the As keyword in the argument declaration. For example, the following function accepts a string and an integer:
Function Reverse (S As String, ByVal n As Integer) ' Reverses the first n characters in S. Dim Temp As String, i As Integer If n > Len(S) Then n = Len(S) For i = n To 1 Step -1 Temp = Temp & Mid(S, i, 1) Next Reverse = Temp & Right(S, Len(S) - n) End Function
You can declare a procedure argument with a user-defined data type, as shown in the following code.
Type custInfo custName As String custCompany As String custId As Integer End Type Sub PrintList(newCust As custInfo) 'place statements here End Sub
Note that you can pass an argument with a user-defined data type only by reference. For more information, see the following section. For more information about fundamental data types and user-defined data types, see Chapter 2, "Variables, Constants, and Data Types," or see the specific data type in Help.