C# Using Statement in VB.NET

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Been trying to get WinXP themes to work in an Office COM Add-in. I came
across this article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;830033

which had a C# example. All good, until I hit the juicy statement at the
end, which makes it all work:


using( new EnableThemingInScope( true ) )
{
Form1 form1 = new Form1();
form1.CreateControl();
}

What does this mean in a VB.NET context? How does it translate, if at all?

Thanks,

Chris.
 
Chris said:
which had a C# example. All good, until I hit the juicy statement at the
end, which makes it all work:


using( new EnableThemingInScope( true ) )
{
Form1 form1 = new Form1();
form1.CreateControl();
}

What does this mean in a VB.NET context? How does it translate, if at all?

VB.NET 2002/2003 do not have a 'Using' statement. VB 2005 will include this
statement. The code above would translate to the code shown in the listing
below in VB.NET 2002/2003:

\\\
Dim etis As EnableThemingInScope
Try
etis = New EnableThemingInScope(True)
Dim form1 As New Form1()
form1.CreateControl()
Catch

' Place error handling code here.
Finally
If Not etis Is Nothing Then
etis.Dispose()
End If
End Try
///
 
Back
Top