AnsweredAssumed Answered

VB.NET Variant Manager Problem

Question asked by thomas.feigenspan on Sep 28, 2017
Latest reply on Jan 30, 2018 by fuba

When I try to access Variant Manager via Automation to retrieve Variant Information I'm experiencing a strange behaviour under VX2.1. In the first run everything finishes successfully, but when I try a second time it fails...

 

This is a sample script:

VB.NET

Private Sub VariantManager()

     Dim vmDocument As MGCVARIANTGUI.VMDocument

     Dim vmAddin As Object = PcbApplication.Addins("Variant Manager")

     If vmAddin Is Nothing Then Exit Sub

     vmAddin.Visible = True

     vmDocument = VmAddin.Control.VariantGUIApplication.VMDocument

     For i As Integer = 1 To vmDocument.Variants.Count

          With vmDocument.Variants.Item(i)

               MsgBox( .Name & ", " & .Number & ", " & .Description )

          End With

     Next

End Sub

VBS

Dim vmDocument, vmAddin

Set vmAddin = Addins( "Variant Manager" )

vmAddin.Visible = True

Set vmDocument = vmAddin.Control.VariantGUIApplication.VMDocument

For i = 1 To vmDocument.Variants.Count

    With vmDocument.Variants.Item(i)

        MsgBox( .Name & ", " & .Number & ", " & .Description )

    End With

Next

 

The VBS runs fine every time, the VB.NET fails at the second attempt (hangs at "For i As Integer = 1 To vmDocument.Variants.Count"). Then I have to restart Xpedition to make it work again, and it fails in the second try.

 

Does anyone else have the same issue? Mentor doesn't help me, because they don't provide Automation VB.NET support.

Outcomes