Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > create Interface object
 

create Interface object

I have the VB.NET code as,

Imports OPCSystemsInterface
Public Class OPCselectserver
Public Sub ListAllServers()
Dim srv() As String = {}
Dim srvlist As OPCSystemsInterface.IOPCSystems ' Here I get the Null reference error
Try
srv = srvlist.GetListOfOPCServers("Localhost")
MsgBox(srv1.Length) ' it will show the number of available OPC servers
Catch ex As Exception
MsgBox(ex.ToString)
End Try
EndSub
End Class

Here I create object of OPCSystemsInterface.IOPCSystems as srvlist
It gives error as null reference exception.
so please tell me how to declare object of the interface 'IOPCSystems'
I want use this object for listing OPC servers in the PC.
OPCSystemsInterface is the NameSpace which contains interface IOPCSystems
Manish Panchal  Saturday, September 12, 2009 6:44 AM
In the simplest case, you need to finda class that implements the interface and do something like the following:

Dim srvlist As OPCSystemsInterface.IOPCSystems = New putNameOfAClassThatImplementsIOPCSystemsHere

Sometimes a constructor is not available and you need to call some method to get the instance instead of using the New keyword. The best thing to do at this point will be to check the documentation for th ecode you are trying to call.
BinaryCoder  Saturday, September 12, 2009 11:44 PM
In the simplest case, you need to finda class that implements the interface and do something like the following:

Dim srvlist As OPCSystemsInterface.IOPCSystems = New putNameOfAClassThatImplementsIOPCSystemsHere

Sometimes a constructor is not available and you need to call some method to get the instance instead of using the New keyword. The best thing to do at this point will be to check the documentation for th ecode you are trying to call.
BinaryCoder  Saturday, September 12, 2009 11:44 PM

You can use google to search for other answers

Custom Search

More Threads

• How to change Button Text inside the DataGridViewButtonColumn for a Row ?
• Winforms datagrid sorting
• Forcing a new new row in datagridview
• DataTable Acts As Intermediator For DataGridView
• What can I use instead of 'DataGridView.Loaded event'?
• how can we have a datagrid with vertical header ? (webform)
• how to update tables data one server to another using vb.net
• Datagrid binding problem
• Graphic artifacts when horizontally scrolling DataGridView
• datagridview - checkbox not functioning