Demo 5 - UserForms

When migrating UserForms from VBA to AutoCAD.NET, I didn't explain the changes required to the code for displaying the migrated UserForm. The migrated VBA function is converted to:

Sub RunMe()
  UserForm1.Show()
End Sub

This should be changed to:

Sub Sub RunMe()
  Dim frm As New UserForm1
  Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm)
End Sub 

The correct code is shown in the <3 - SimpleForm\EarlyBinding_VB6Conv\VBA2VBProject.NET> project.

Note that this is different from the standard .NET way of showing forms (frm.ShowModal()), and is required to make the form behave correctly in the AutoCAD environment.

Setting up an AutoCAD .NET project in VB Express

Since recording this presentation, the ADN team have produced an AutoCAD .NET Project Wizard for Visual Studio (Express). See here for details.

Using on a non-English OS

The UserForm translator may fail when used on an operating sustem with a locale setting that uses a comma (',') as a decimal separator instead of a period ('.'). The workaround is to go to Control Panel>Regional and Language Options and temporarily set the Language to “English (United States)" before running the translator.

Bugfixes

6/22/9 - Fixed some minor bugs in the 'magic macro'.

 

 

This document last updated: 7th July 2009