Ciper123
Ciper123

Reputation: 131

Invoke not working on VS2008

So I have this line of code:

Invoke(Sub()pt = PictureBox1.PointToScreen(bounds.Location))

I was able to use it on VS2013 without error but when I transferred to VS2008 there was an error saying "Expression Expected". Is there a way to use this code in VS2008? because I don't know how to use delegates.

Upvotes: 1

Views: 232

Answers (1)

Hans Passant
Hans Passant

Reputation: 942256

Using Sub in a lambda expression was not possible until VS2010. The logical alternative is:

    Dim pt As Point = DirectCast(Me.Invoke(Function() PictureBox1.PointToScreen(Bounds.Location)), Point)

Which is in fact superior to the original since it doesn't have to capture any variables.

Upvotes: 2

Related Questions