Share via

Passing PointF as Optional Parameter

S K 1 Reputation point
2021-07-29T06:15:21.347+00:00

Blockquote

I want to pass PointF as optional Parameter. But I am finding it difficult to assign default value for PointF.
I can't assign Nothing. If I do it becomes (0,0) which can be working value hence can't be used as a unique default value.
I am not able to assign any other value. I tried (Optional P1 As PointF = New PointF(-100, -100) but it does not work.

Public MyFunc(Optional P1 As PointF = ????)

Please help.

Developer technologies | VB
0 comments No comments

1 answer

Sort by: Most helpful
  1. Viorel 127K Reputation points
    2021-07-29T07:58:50.157+00:00

    Try something like this:

    Sub MyFunc(P1 As PointF)
       . . .
    End Sub
    
    Sub MyFunc()
       MyFunc(New PointF(-100, -100))
    End Sub
    

    You can also provide different bodies for these functions.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.