You can try using a colon. But you cannot put the body of function / sub on the same line as the declaration of the function / sub.
Public Sub derp(x As Integer) MsgBox(x) : MsgBox("Hello, world") : End Sub
You can also try using an action delegate. But it can only have 1 operator if you want to put them in 1 line.
Public herp As Action(Of Integer) = Sub(x) MsgBox(x)
If you want to have multiple lines, you write them like this (you can use colons if you want):
Public herp As Action(Of Integer) = Sub(x) MsgBox(x) MsgBox("Hello, world") End Sub
Use the Func delegate if you want to return a value instead of the Action delegate.
source share