How to convert this C# code into VB 2005 code?

M

Mika M

This should be easy, but I don't figure it out...

private void setInfoText(string text)
{
if (this.statusStrip1.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate()
{
this.pnlInfo.Text = text;
});
}
else
{
this.pnlInfo.Text = text;
}
}

....should be about...

Private Sub SetInfoText(text As String)
If (Me.StatusStrip1.InvokeRequired) Then
Me.Invoke((MethodInvoker)delegate() <-- ???
Me.pnlInfo.Text = text
)
Else
Me.pnlInfo.Text = text
End If
End Sub
 
H

Herfried K. Wagner [MVP]

Mika M said:
This should be easy, but I don't figure it out...

private void setInfoText(string text)
{
if (this.statusStrip1.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate()
{
this.pnlInfo.Text = text;
});
}
else
{
this.pnlInfo.Text = text;
}
}

...should be about...

Private Sub SetInfoText(text As String)
If (Me.StatusStrip1.InvokeRequired) Then
Me.Invoke((MethodInvoker)delegate() <-- ???
Me.pnlInfo.Text = text
)
Else
Me.pnlInfo.Text = text
End If
End Sub
--

Note that VB does not support real anonymous methods, it only supports
anonymous Lambda expressions. Nevertheless, in your case you can pass a
delegate to 'SetInfoText' to the 'Invoke' method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top