Use COPC32 on Visual Basic.NET

This tutorial will assist you how to utilize COPC32 on Visual Basic.NET. You have to set up COPC32 on your system before develop SCADA with Visual.NET and also COPC32 ActiveX control. As well as we expect that you have OPC Server on your regional system already.

We will create the straightforward kind to review as well as write to OPC web server on neighborhood systems. However you would certainly, like to attach to remote OPC web server. Please configure DCOM on both server and also client side by refer to tutorial of KEPWare at

The kind we will develop is displayed in Number 1.

Number 1

When customer insert numeric value in textbox and also click button ‘& lsquo; Write ‘, COPC32 will certainly contact OPC tag and also show its value on ‘& lsquo

  1. ; Label1 ‘. Open Visual Studio.NET and crate new task with VB.NET

Figure 2

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

rdquo;. 2. Add COPC32 ActiveX control right into tool kit by pick menu Tools > > Add/Remove Toolbox Things & hellip;

Number 3

After that pick COPC32 shown in Figure 4.

Number 4

Then click “& ldquo;

OK & rdquo; 3. Crate a switch, a textbox and also label on form like received Number 1
Read here At our site

. 4. Select in tool kit and also drag out the kind.

5. Right click on COPC32 control on the kind as well as choose ActiveX buildings.

Number 5

Set update rate to 100 msec. And choose OPC Server name to wanted OPC Web server. You need to enter IP address or machine name in ‘& lsquo; nodname ‘ textbox if you would love to link to remote OPC server over the network.

Figure 6

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

Figure 7

Click OK.

This OPC Tag could be Legible as well as Writable. You can look at your OPC Server like displayed in Figure 8.

Number 8 OPC Tag homes.

Number 9 Configure OPC tag index number = 0

As well as click OK to exit residential property web pages.

Note: You can configure linked OPC tags by import OPC tag list from CSV documents which export from OPC Web server. Please refer to

As well as see “& ldquo; Exactly how to load OPC tags from CSV file”&

rdquo;. 7. Dual click the type to enter to Form_Load event code view.

8. Develop the code to attach to OPC server as well as get worth of OPC tag index 0 to show on Label1.

Personal Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Manages MyBase. Lots


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

End Below

Keep in mind: If you have set up other OPC tag such as OPC tag index number = 1. You can get its worth utilizing ‘& lsquo

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

occasion name from

dropdown. Number 10 And create the code like complying with

Exclusive 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 before separate from OPC Web server.

10. Back to design view. Double click COPC32 control on the form to get in to “& ldquo; datChange & rdquo; occasion code view. Then develop the code to show OPC tag worth on Label1 when the vale of OPC tag we are linked has actually transformed.

Private Below 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 develop style sight. Dual click button ‘& lsquo; Compose ‘. Then produce code to create vale to OPC tag which has index number = 0.

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

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

End Sub

12. Test program by click F5. Put the number into textbox and also click ‘& lsquo; Compose ‘. You could see the vale shown in label amounts to your go into number.

Number 11

The total relevant code is shown in Number 12.