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

  • Thread starter Thread starter Mika M
  • Start date Start date
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
 
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.
 
Back
Top