Use COPC32 on Visual Basic.NET

December 2, 2020 7:28 am Published by

This tutorial will lead you just how to use COPC32 on Visual Basic.NET. You have to mount COPC32 on your system prior to produce SCADA with Visual.NET and COPC32 ActiveX control. As well as we suppose that you have OPC Server on your neighborhood system currently.

We will produce the basic type to read and write to OPC server on local systems. Yet you would, like to connect to remote OPC server. Please configure DCOM on both server and also client side by refer to tutorial of KEPWare at

The kind we will produce is shown in Number 1.

Number 1

When user insert numerical value in textbox and click button ‘& lsquo; Compose ‘, COPC32 will contact OPC tag as well as show its value on ‘& lsquo

  1. ; Label1 ‘. Open Visual Studio.NET as well as crate new job with VB.NET

Figure 2

Type the name of this project as “& ldquo; TestCOPC32VBNET &

rdquo;. 2. Include COPC32 ActiveX control right into toolbox by pick food selection Tools > > Add/Remove Tool kit Items & hellip;

Figure 3

After that pick COPC32 displayed in Number 4.

Figure 4

After that click “& ldquo;

OK & rdquo; 3. Crate a switch, a textbox as well as label on kind like received Figure 1
by link free COPC32 download website

. 4. Select in tool kit as well as drag on the kind.

5. Right click COPC32 control on the form as well as pick ActiveX homes.

Figure 5

Establish upgrade rate to 100 msec. As well as pick OPC Web server name to wanted OPC Server. You need to go into IP address or equipment name in ‘& lsquo; nodname ‘ textbox if you wish to connect to remote OPC web server over the network.

Figure 6

6. Select OPC Tag you would like to connect to.

Number 7

Click OK.

This OPC Tag could be Legible as well as Writable. You can check on your OPC Web server like displayed in Number 8.

Figure 8 OPC Tag residential properties.

Number 9 Configure OPC tag index number = 0

And also click OK to leave property pages.

Keep in mind: You can configure linked OPC tags by import OPC tag list from CSV data which export from OPC Web server. Please describe

And also see “& ldquo; How to load OPC tags from CSV data”&

rdquo;. 7. Double click the form to go into to Form_Load occasion code view.

8. Produce the code to connect to OPC web server and also obtain worth of OPC tag index 0 to show on Label1.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase. Tons


Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))

End Below

Note: If you have configure other OPC tag such as OPC tag index number = 1. You can obtain its worth utilizing ‘& lsquo

; GetVl( “1)’”. 9. Select & ldquo; Closing & rdquo;

event name from

dropdown. Figure 10 As well as produce the code like following

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Deals with MyBase. Closing



End Below

Note: We use “& ldquo; Application.DoEvents()” & rdquo; to waiting various other job to finish prior to detach from OPC Server.

10. Back to develop sight. Double click on COPC32 control on the kind to get in to “& ldquo; datChange & rdquo; event code sight. Then create the code to display OPC tag value on Label1 when the vale of OPC tag we are connected has altered.

Private Sub Axcopc1_datChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles Axcopc1.datChange

Label1.Text = Convert.ToString(Axcopc1.GetVl( 0 ))

End Sub

11. Back to form design sight. Double click switch ‘& lsquo; Write ‘. Then develop code to compose vale to OPC tag which has index number = 0.

Exclusive Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Manages Button1.Click

Axcopc1.opcWrt(0, Convert.ToDouble(TextBox1.Text))

End Below

12. Examination program by click F5. Put the number right into textbox as well as click ‘& lsquo; Write ‘. You can see the vale received tag is equal to your enter number.

Figure 11

The total relevant code is shown in Figure 12.

Categorised in:

This post was written by admin

Comments are closed here.