?? define.bas
字號:
Attribute VB_Name = "define"
Option Base 1
Option Explicit
Public ItemServerHandles() As Long
Public ItemServerErrors() As Long
Public IsConnectSuccess As Boolean
Public Const DcsComputer = "HIS0124" '計算機名
Public Const OpcServerName = "Yokogawa.CSHIS_OPC" 'dcs提供的opc server名
Public Const GroupName = "Group_First"
Public Const ItemCount = 51 '點數(現在點數為51
Public Const RateTime = 1000 '刷新率
Public Const iSourceDevice = 2
Public OPCItemIDs(ItemCount) As String '用于存放點值
Public ClientHandles(ItemCount) As Long
Public Values(ItemCount) As Variant
Public ItemErrorHandles(ItemCount) As Long
Public Sub GetTagName()
Dim i As Long
Dim ErrorStr As String
i = 1
On Error GoTo readFileErr
Open "c:\citect\TagName.Txt" For Input Access Read Lock Read Write As #1
Do While Not EOF(1) ' 檢查文件尾。
Line Input #1, OPCItemIDs(i) ' 讀入一行數據。
i = i + 1
Loop
Close #1
' OPCItemIDs(1) = "CHANNEL1.DEVICE1.TAG1"
' OPCItemIDs(2) = "CHANNEL1.DEVICE1.TAG2"
' OPCItemIDs(3) = "CHANNEL1.DEVICE1.TAG3"
' OPCItemIDs(4) = "CHANNEL1.DEVICE1.TAG4"
' OPCItemIDs(5) = "CHANNEL1.DEVICE1.TAG5"
Exit Sub
readFileErr:
Close #1
ErrorStr = "讀取文件tagname.txt失敗,請檢查文件夾citect中的tagname.txt文件,如果損壞,請用備份文件"
Call OpcForm.DisplayOPC_COM_ErrorValue(ErrorStr, 1001)
End Sub
Public Sub WriteValueToFile()
Dim i As Long
Dim ErrorStr As String
On Error GoTo writeFileError
Open "c:\yokogawa.txt" For Output Access Write Shared As #2
For i = 1 To ItemCount
Print #2, CStr(Values(i)) + Chr(13)
Next i
Close 2#
Exit Sub
writeFileError:
On Error Resume Next
Close #2
Exit Sub
ErrorStr = "寫文件失敗,請檢查文件夾DDJY中的yokogawa.txt文件,如果損壞,請用備份文件"
Call OpcForm.DisplayOPC_COM_ErrorValue(ErrorStr, 1000)
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -