- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This Sub will be quite simple to convert but there are a few things you'll need to fix VB.NET program. The first step is to just copy and paste it into a VB.NET program. You'll see a bunch of problems highlighted inside Visual Studio. For example, the Set statement is not longer needed or even supported so you need to delete those. (I think depending on the version of Visual Studio is might do this automatically.) Where you declare variables that are an Inventor type you'll need to either full declare them or add a an Imports statement at the top of your program. For example:
Dim wpls As WorkPlanes
becomes
Dim wpls As Inventor.WorkPlanes
Or you can add "Imports Inventor" at the very top of the code and then the original statement will still work.
VB.NET also requires that enum values be fully qualified so
If invDoc.DocumentType = kPartDocumentObject Then
becomes
If invDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
Intellisense can help with these. Just type in the equals again and it will display a list of valid enums and picking one will give you the fully qualified name.
As I said, a lot of the problems Visual Studio will point out to you and they're all easy to fix when you know what to do. There are some other differences that are harder to find. I presented a class at AU a few years ago about converting VBA programs to Add-Ins and discussed this a bit in there. I've attached the paper I wrote for that class. Hopefully it will help.
I think it's best to recognize up front, which it seems you already have, that VBA and VB.NET are different languages and it takes a little bit to get used to but once you do it's difficult to go back.
