Here is a little trick to learn how to create objects in code and ensure you have all of the supporting code with it:
- Start a new project as you normally do
- Add a driver to the form
- In Solution Explorer, at the top you will see an icon for Show All Files. Click that to enable it
- Now you should have an option to drill down into the MainForm
- Drill down into the MainForm.vb and look for MainForm.Designer.vb
- Right click Mainform.Designer.vb and select View Code
- Look for all the code associated to the driver instance
You will see something like this:
Declaring the object instance and adding to the components collection to ensure proper disposal
Me.EthernetIPforSLCMicroCom1 = New AdvancedHMIDrivers.EthernetIPforSLCMicroCom(Me.components)
Setting the properties
'
'EthernetIPforSLCMicroCom1
'
Me.EthernetIPforSLCMicroCom1.CIPConnectionSize = 508
Me.EthernetIPforSLCMicroCom1.DisableSubscriptions = False
Me.EthernetIPforSLCMicroCom1.IniFileName = ""
Me.EthernetIPforSLCMicroCom1.IniFileSection = Nothing
Me.EthernetIPforSLCMicroCom1.IPAddress = "192.168.1.233"
Me.EthernetIPforSLCMicroCom1.IsPLC5 = False
Me.EthernetIPforSLCMicroCom1.PollRateOverride = 500
Me.EthernetIPforSLCMicroCom1.Port = 44818
Me.EthernetIPforSLCMicroCom1.Timeout = 5000
Declaring the variable as Friend Scope (You may use Private scope unless you refer to the driver from other forms)
Friend WithEvents EthernetIPforSLCMicroCom1 As AdvancedHMIDrivers.EthernetIPforSLCMicroCom
Following this pattern will ensure you do everything necessary to properly create, setup, and dispose of the object.