Purchase our legacy source code for OPC communications.
If you would like to integrate OPC data into your Visual Basic 6.0 application
and would like to have access to all source code then OPC for Visual Basic is
your best selection.
Looking for easy to use data access and form components?
OPC
Controls.NET Components are the best choice for Visual
Studio.NET applications.

OPC Controls is the best choice for Visual Basic 6.0.
This toolkit includes source code for both Visual Basic.NET 2003 and
Visual Basic 6.0.
Existing OPC for VB customers contact Open Automation Software for your free update of
VB.NET code.
OLE for Process Control client developed with Visual Basic using the OPC
Automation Interface 2.0. Free high-speed example can be download here
which supports tag browsing and high speed asynchronous event driven
communications. By developing several custom OPC clients using Visual
Basic, Open Automation Software has perfected the implementation of high-speed connections with low
CPU load.
The source code for this application can be purchased from Open Automation
Software. The application provides an open development solution to OPC with
tag browsing and high-speed communications with low overhead. The source code
example simplifies the connection to the OPC Automation Interface 2.0.
Automation interface provided with installation of application.




To
purchase product and receive source code visit our
on-line
store, contact your Open Automation Software authorized distributor, or download the
Open Automation Software order form and fax the form with purchase order or credit
card information to 1-(303)-679-8698.
Download and CD only include compiled VB 6.0 example. After purchase source
code of Visual Basic 6.0 and Visual Basic.NET 2003 will be provided.
Pricing
Corporate License:...............$ 695.00 US
(Corporate License Includes Source Code in
Visual Basic 6.0 and Visual Basic.NET 2003)
All Source code included with application

Remote and local tag browsing code included with Form.

Extremely fast data update rate, several thousand values per second.

Examples:
' Add OPC items to OPC server objects
Public Sub AddOPCItems(ItemArray() As String, AccessPathArray() As
String)
Dim ServerString As String
Dim NetworkNode As String
Dim ServerStringStart As Integer
Dim ShortItemString As String
Dim AccessPath As String
Dim i As Integer
Dim itemIndex As Integer
Dim ServerExists As Boolean
Dim Success As Boolean
Dim NumberOfItemsToAdd As Integer
Dim OPCItem As String
Dim positionInArray As Integer
NumberOfItemsToAdd = UBound(ItemArray)
For itemIndex = 1 To NumberOfItemsToAdd
OPCItem = ItemArray(itemIndex)
AccessPath =
AccessPathArray(itemIndex)
positionInArray =
ModuleDataItems.AddItem(OPCItem, AccessPath)
If positionInArray > 0 Then
i = 1
If
Left$(OPCItem, 2) = "\\" Then ' get node name
i = 3
Do While i <= Len(OPCItem)
If Mid(OPCItem, i, 1) = "\" Then
Exit Do
End If
i = i + 1
Loop
If i > 3 Then
NetworkNode = Mid$(OPCItem, 3, (i - 3))
ServerStringStart = i + 1
i = i + 1
Else
NetworkNode = ""
ServerStringStart = 3
End If
Else
NetworkNode = ""
ServerStringStart = 1
End If
Do While i <=
Len(OPCItem)
If Mid(OPCItem, i, 1) = "\" Then
Exit Do
End If
i = i + 1
Loop
ShortItemString = Right(OPCItem, Len(OPCItem) - i)
ServerString
= Mid(OPCItem, ServerStringStart, (i - ServerStringStart))
If i > (Len(OPCItem))
Then
i = Len(OPCItem)
End If
ServerExists
= False
If
NumberOfServers < 1 Then
ServerExists = False
Else
For i = 1 To NumberOfServers
If
ServerArray(i).ServerName = ServerString And ServerArray(i).NetworkNode
= NetworkNode Then
ServerExists = True
Exit For
End If
Next i
End If
If Not (ServerExists) Then
NumberOfServers = NumberOfServers + 1
ReDim
Preserve ServerArray(1 To NumberOfServers)
Set
ServerArray(NumberOfServers) = New ClassOPCData
Success =
ServerArray(NumberOfServers).StartServer(NetworkNode, ServerString)
If Success
Then
Else
MsgBox ServerString + " failure", vbCritical, "OPC Server Error"
End If
i =
NumberOfServers
End If
ServerArray(i).AddItem
ShortItemString, positionInArray, AccessPath
ModuleDataItems.SetServerNumber i
End If
Next itemIndex
For i = LBound(ServerArray) To UBound(ServerArray)
ServerArray(i).AddItemsToGroup
Next i
RefreshItems
End Sub
' Send value to OPC server to write item
highlighted
Private Sub CommandWriteData_Click()
Dim indexforWrite As Integer
Dim writeValue As Variant
' If desire to write to string OPC item, eliminate check
If IsNumeric(TextWriteData.Text) Then
indexforWrite = indexOfData +
indexOfWrite
writeValue = Val(TextWriteData.Text)
ServerArray(ModuleDataItems.ServerNumbers(indexforWrite)). WriteData
writeValue, indexforWrite
Else
MsgBox "Not a valid number",
vbCritical, "Invalid data to write"
End If
End Sub
' Event from automation that values of changed or response for
AsyncRefresh
Private Sub GroupOPC_DataChange(ByVal TransactionID As Long, ByVal
NumItems As Long, ClientHandles() As Long, ItemValues() As Variant,
Qualities() As Long, TimeStamps() As Date)
On Error GoTo ErrHandler
Dim i As Integer
For i = 1 To NumItems
If Qualities(i) = 192 Then ' Good
Data
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) =
ItemValues(i)
Else
Select Case Qualities(i)
Case 0 ' Bad
data, reason unknown
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Bad Data"
Case 1 '
Configuration Error
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Config
Error"
Case 2 ' Not
connected
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Not
Connected"
Case 3 '
Device Failure
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Device
Failure"
Case 4 '
Sensor Failure
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Sensor
Failure"
Case 5 '
Communication Fail, but last known value avaialble
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Comm. Fail
" + ItemValues(i)
Case 6 '
Configuration Error
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Comm.
Fail"
Case 7 ' Out
of Service
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Out of
Service"
Case 16 '
Uncertain Value
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Uncertain"
Case 17 '
Uncertain Value
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Uncertain
" + ItemValues(i)
Case 20 '
Sensor Problem
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Sensor
Bad"
Case 21 '
Limits Exceeded
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Limit
Exceeded"
Case 22 '
Uncertain Sub-Normal
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) =
"Sub-Normal"
Case 198 '
Good with local override
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) = "Ov. " +
ItemValues(i)
Case Else '
Left field
ModuleDataItems.OPCValues(PositionArray(ClientHandles(i))) =
"Bad-Unknown"
End Select
End If
If ModuleDataItems.OPCValueUpdates < 2147483646 Then
ModuleDataItems.OPCValueUpdates =
ModuleDataItems.OPCValueUpdates + 1
End If
Next i
FormData.RefreshData
Exit Sub
ErrHandler:
Resume Next
End Sub