Application Events in VB

I do not work much in VB, but somebody recently asked how to subscribe to the Revit application events in that language. There is no VB sample for this in the Revit SDK samples, so I created the following little solution to demonstrate it.

The steps to create it are exactly the same as for a C# project, and were actually described in detail for both C# and VB in the post on

Debugging a Revit Add-In
, but here is the really short version:

  • Create a new class library project
  • Reference RevitAPI.dll
  • Set its ‘Copy Local’ flag to false
  • Derive your class from IExternalApplication
  • Implement the member methods

I have copied the full Visual Studio solution AppEventsVb
here.
It is very straight forward to create from scratch, actually, and using Intellisense as much as possible really helps. For instance, the moment I typed ‘Implements IExternalApplication.OnShutdown’, the skeleton code for two methods is automatically added by Visual Studio.


Comments

2 responses to “Application Events in VB”

  1. Also useful for anyone who is a VB coder and wants to convert samples is the many VB to C# code converters available:
    http://www.google.com.au/search?source=ig&hl=en&rlz=1G1GGLQ_ENAU244&=&q=C%23+to+VB+code+converter&btnG=Google+Search&meta=
    such as:
    http://www.developerfusion.com/tools/convert/csharp-to-vb/
    and
    http://www.carlosag.net/Tools/CodeTranslator/
    they may not do whole projects but they can help you decipher the samples!

  2. Hi Rod,
    Thank you very much for your comment. It prompted me to write a post mentioning Lutz Roeder’s wonderful Reflector analyser and IL decompilation tool, available at
    http://www.aisto.com/roeder/dotnet
    I am in the process of posting it right now …
    Thank you for the inspiration!
    Best regards,
    Jeremy

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading