AnsweredAssumed Answered

How to rewrite this line from VBA into VB.NET?

Question asked by Ross John on Apr 12, 2017
Latest reply on Apr 13, 2017 by Ross John

Hi Forum,

 

I am following the example from Ivana Kolin to save the selections and then reuse them. Saving Assembly selection set

 

Her code was in VBA. I would like to rewrite it into VB.NET. I could actually do the most job on myself. Except one line. I would like to ask, how to "translate" swComponent(j).Select True from VBA into VB.NET.

 

Hier I would like to paste code from Inana Kolin from the link above, with my question...

Sub main()

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2

Dim SelMgr As SldWorks.SelectionMgr

Dim swComponent() As SldWorks.Component2

Dim i As Integer

Dim j As Integer

Set swApp = GetObject(, "SldWorks.Application")

 

Set Part = swApp.ActiveDoc

Set SelMgr = Part.SelectionManager

i = SelMgr.GetSelectedObjectCount

ReDim swComponent(i)

For j = 0 To i

Set swComponent(j) = SelMgr.GetSelectedObjectsComponent3(j, -1)

Next j

 

Part.ClearSelection

 

For j = 0 To i

If Not swComponent(j) Is Nothing Then

swComponent(j).Select True ' Question: How to rewrite this line into VB.NET?

End If

Next j

End Sub

Outcomes