vb.netvisual-studio-2013declarationrealbasicxojo

How do I pass parameters to a method both as normal and like a property?


In RealBasic (now Xojo), which I'm leaving to the past, I used to be able to declare a method like this:

Sub MyCoolSub(param1 as string, Assigns parameter2 as integer)
Do
'Waste CPU time scrying the universe.
Loop
End Sub

And then call it in this way:

MyCoolSub("Answer")=42

Now I'd want to replicate this behaviour in VB.Net.

The closest thing I stumbled upon is the Property's clauses, but VS does not let me add parameters to it that would however require some overhead which decreases the convenience of this type of declaration.

Do you have any better suggestion?

PS. As a side question I would be pretty happy to know that there is a way to comment with "//" in VB.Net, as I'm not that comfortable with the apostrophe character. Is there any thing as a VS comment characters list? Maybe an extension could do it...


Solution

  • When I look at the documentation for the Xojo Assigns keyword the closest thing I can think of is to create a write-only property like this:

    Public WriteOnly Property theVolume(a As Integer, b As Integer) As Integer
        Set(c As Integer)
            Debug.WriteLine("a={0}, b={1}, c={2}", a, b, c)
        End Set
    End Property
    

    theVolume(1, 2) = 3
    

    a=1, b=2, c=3