|
-
Jan 3rd, 2000, 11:47 PM
#1
Thread Starter
New Member
Hi.
In VB5, how can I pass a user function as
parameter to other user function?
Or if there is a way to pass a pointer to
the function, how can I call it?
Thanks in advance.
-
Jan 4th, 2000, 01:58 AM
#2
Hyperactive Member
check out the AddressOf operator
eg.
Call TheFunction(p1, p2, AddressOf MyFun)
(that argument has to be declared as long)
But you can't (at least not using straight VB code) use a pointer to call the function; it's implemented in VB to use in API calls.
-
Jan 4th, 2000, 02:50 AM
#3
Thread Starter
New Member
I'd like to do something like...
Function F1(x As Double) As Double
F1 = Sin(x) * Cos(x)
End Function
Function F2(x As Double) As Double
F2 = Tan(x)
End Function
Sub Draw(F)
Dim x, y As Double
For x = -10 To 10 Step 0.1
y = F(x) 'call to passed function
'here draw point (x,y) ...
Next
End Sub
Sub DrawAll()
Draw F1
Draw F2
End Sub
I know how to do it in Delphi,
but I'm new in VB.
If you know how to do it,
please let me know.
Thanks.
-
Jan 4th, 2000, 12:20 PM
#4
Can you give an example of what you want to do?
------------------
Marty
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|