次のコードでは、コンパイル時エラーが発生します。
ByRef Argument type mismatch.
しかし、i、jの宣言を次のように変更すると:
Dim i As Integer
Dim j As Integer
エラーはなくなります。なんで?
Private Sub Command2_Click()
Dim i, j As Integer
i = 5
j = 7
Call Swap(i, j)
End Sub
Public Sub Swap(ByRef X As Integer, ByRef Y As Integer)
Dim tmp As Integer
tmp = X
X = Y
Y = tmp
End Sub