2 Sep 2020

learnforge Modify Your Models - VB.NET

Have just written here about converting the AppBundle generated by the Visual Studio project template for Design Automation for Inventor to VB.NET. The same utility I used there, can also be used to convert the ASP.NET Core C# project shown on the learnforge website to VB.NET 
The finished tutorial can be found here and that was my starting point.

I only focused on converting the ASP.NET Core project, because that is what everyone can use no matter which desktop product they are interested in.

Once I installed the Code Converter VS extension, I could open the solution, right-click on the "forgesample" project and click "Convert to VB"

Convert to VB

When I tried to compile the project I ran into quite a few errors:Compile issues

The first issue was the same one I found during the AppBundle conversion, i.e. the code was using "dynamic" instead of "Object". So I just had to search for "dynamic" in the entire solution/project and replace them all:

dynamic to Object  
The naming of one of the variables was clashing with a class name, so just had to rename it to something else:

Renaming activity to act

Then had to add "Imports System.Text" so that "Encoding" could be found:

Imports System.Text

And last, I had to explicitly cast the input parameter of RestClient() to a String using CType():

Use CType to cast input parameter to String

As you can see in the picture at the top of the article, after all this, I managed to run the project just fine. Here is the finished project: https://github.com/adamenagy/Container/blob/master/learn.forge.designautomation-VB.NET.zip

Note: while I was fixing the issues in the converted project, I could hardly find any relevant VB.NET samples on the net. All the useful ones were C# and the VB.NET ones tended to be about something else than what I searched for. 
My feeling is that for web development VB.NET is not as popular as C#, so in the long run, it's probably worth investing in learning C# if you want to stick with Microsoft web technologies

Tags:

Related Article

Posted By

Adam Nagy

Follow @AdamTheNagy Adam Nagy joined Autodesk back in 2005 and has been providing programming support, consulting, training and evangelism to external developers. He started his career in Budapest, then worked in Prague for 3 years and now lives in South England, UK. At the moment focusing on Inventor and Fusion 360, plus cloud and mobile related technologies. Adam has a degree in Software Engineering and has...