passing Canvas to Sub

enonod

Well-Known Member
Licensed User
Longtime User
If I have cvsA and cvsB as Canvases and wish to pass them in turn to a Sub that draws on each, can I use...

Sub Draw(fred)
Rect1.Initialize(x,y, etc)
fred.DrawRect(Rect1, etc)
...
End Sub

such that fred can be either canvas? Not being the result of an action I cannot distinguish by using sender.

Thank you
 

stevel05

Expert
Licensed User
Longtime User
You'll need to define the Sub as

Sub Draw(fred As Canvas)

But yes it should work.
 
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Thank you for that and yes I would have forgotten the As Canvas.
 
Upvote 0
Top