PLC to VB - How to handle PLC data With VB


Thread Starter


Hi, I would like to know what is the best way to write a code for establishing a connection between vb and plc? I just want to read data from plc by using vb....can anyone help me? Thank you
[More information about this problem is provided below]

i need a source code in vb in which can:-

1)establish a connection with opc server
2)read data from plc
3)write data from plc

can anyone help me?

William Sturm

I would suggest an OCX or .NET driver.  Contact Automated Solutions or Software Toolbox for examples.

Bill Sturm
Abbeytronics LLC
What make and model PLC (A-B micrologix, GE 90-30, etc.), and what type of interface (Ethernet, serial, etc.)?

Fred Loveless

Kepware provides several VB 6 and code examples With its OPC Server. These are unsupported samples using the OPC Faoundations OPC DA 2.0 Automation Wrapper.

We also have a .Net development package called Client Ace which does have support.

You can also find examples of code at

Fred Loveless
Kepware Technologies
I wrote client and server programs in Visual Basic that uses a PC com port (RS232) to communicate via Modbus with a Modicon Micro PLC.

These programs outline the basis for the Modbus protocol and should be easily translated to other programming languages.

Follow the link below to get the program examples.
Actually, here is some info. I used toolbox from software toolbox. Now I want it to be connected to my OPC server name which is "CoDeSys.OPC.02".

Here is some codes. I don't know, where is the problem. I used stange PLC.

Private Sub iThermometerX1_OnPositionChange()
Dim result As Long

iThermometerX1.SetOPCItemServerName = "CoDeSys.OPC.02"
iThermometerX1.SetOPCItemGroupName = "Testing"
iThermometerX1.SetOPCItemItemName = "SE_UNITS.Unit[1].SetValues.SetValue[1].ManualValue"
iThermometerX1.SetOPCItemUpdateRate = 500

Is it the correct way to establish a connection or there is any other good way?
OPC using KepWare is the only practical way of doing it. I just finished a program that uses a PC as a human interface. It's cheaper than having to change touchscreen displays or multi function displays in an agressive environmnent. It takes some time to get used to the code, but KepWare has some examples that are easily adapted to single PLC applications.