OLE简单点啊!不要搞那么复杂啊!
定义API函数读取你计算机的名字:
Private Declare Function GetComputerName Lib "Kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
OLE方式读取WINCC的变量的数据:
Dim ComputerName As String, i As Long
i = 255
Dim wincc As Object
ComputerName = String(i, 0)
GetComputerName ComputerName, i
ComputerName = Left(ComputerName, i)
Set wincc = CreateObject("WinCC-Runtime-Project", ComputerName)
Text1.Text = wincc.GetValue("A")
Text2.Text = wincc.GetValue("B")
SetValue()方法是写数据。
顺便给个例子你看看:
点击此处查看附件