Lets start simple. Open 3DCreate and drop a few components form the eCat to the layout (make sure you have only one session open). Set up a new Visual Basic Console Application project (see Setting Up). After setup go to the module1.vb Tab, which should be the default name of your code, and you will notice the tab is pre-filled with:
Module Module1
Sub Main()
End Sub
End Module
The code will go between the Sub Main() and End Sub statement. For brevity fo reading i will be omitting showing the entire code until very last, and all of the code spinets are assumed to be after the Sub Main(). The first thing you need to do is to connect up to the visual components application. For this we need to open up a com connection. To do this fill in:
Dim vcApp As vcCOM.IvcApplication
vcApp = New vc3DCreate.vcc3DCreate
This creates a variable of type and IvcApplication and fills it with a handle to the open 3dCreate session. This gives you a object that can access all the things in the manual under COM Reference->Base COM API->IvcApplication. If you would have wanted to use IvcApplication2 you would just have said so and the object would have been casted to appropriate. Next let's do something moderately useful lets list each item in the scene and print its name out to the sytem console.
For i = 0 To vcApp.ComponentCount - 1
System.Console.Out.WriteLine(vcApp.getComponent(i).getProperty("Name"))
Next
Now we are done, all that remains is to execute the code. To do so hit F5, you may notice that something happens very fast. That's okay it's supposed to be fast, it would however be nice if we had time to react, and we can instruct the code to stop at a certain place. Move the cursor to the line End Sub and press F9 this creates a ball on the left, this is a break point. A break point instructs the code to wait for user input mid run (see Debugging COM). If you now hit F5 a new window opens with a list of all component names.
And the final Complete code:
Module Module1
Sub Main()
Dim vcApp As vcCOM.IvcApplication
vcApp = New vc3DCreate.vcc3DCreate
For i = 0 To vcApp.ComponentCount -1
System.Console.Out.WriteLine(vcApp.getComponent(i).getProperty("Name"))
Next
End Sub
End Module