'此示例使用ProcPtr来演示函数指针
Declare Function Subtract( x As Integer, y As Integer) As Integer
Declare Function Add( x As Integer, y As Integer) As Integer
Dim myFunction As Function( x As Integer, y As Integer) As Integer
'myFunction现在将赋值给Add
myFunction = ProcPtr( Add )
Print myFunction(2, 3)
'myFunction现在将被赋值给Subtract。注意不同的输出。
myFunction = ProcPtr( Subtract )
Print myFunction(2, 3)
Function Add( x As Integer, y As Integer) As Integer
Return x + y
End Function
Function Subtract( x As Integer, y As Integer) As Integer
Return x - y
End Function