PHP:
' A module to read data from a single channel into an Excel spreadsheet
that is automatically cleared & updated with new data.'
################################################################################
’' RTDX OLE API Status Return codes'
Const SUCCESS = &h0
Const FAIL = &h80004005
Const ENoDataAvailable = &h8003001e
Const EEndOfLogFile = &h80030002
Const members = 10 ' Total number of integers in array'
Option Explicit
Sub read_channel()
Dim rtdx As Object ' object variable'
Dim row, col As Integer ' temporary worksheet indices'
Dim status As Long ' variable for status of RTDX read'
Dim data As Long ' variable for data from RTDX read'
Worksheets("Data").Range("A1:IV16384").Clear ' Clear old data'
Set rtdx = GetObject("", "Debugger.RTDX") ' Get Debugger class object'
' variable RTDX becomes an instantiation of the OLE interface'
status = rtdx.Open("ochan", "R") ' Open channel with name "ochan" for reading'
row = 1 ' Start data display here'
col = 1
Do
status = rtdx.ReadI4(data) ' Read value from data channel'
Select Case status
Case Is = SUCCESS 'if ReadI4 was successful...'
Worksheets("Data").Cells(row, col) = data ' Copy data read into spreadsheet'
col = col + 1
If (col > members) Then ' if reading next column of data...'
row = row + 1 '’ move to next row'
col = 1 '’ column 1'
End If
Case Is = FAIL '’ if ReadI4 failed...'
MsgBox ("Error reading data")
Exit Do
Case Is = ENoDataAvailable '’ if data not yet available...'
MsgBox ("Data not Available")
Case Is = EEndOfLogFile '’ if end of data reached...'
MsgBox ("End of Log reached")
Exit Do
Case Else
MsgBox ("Unknown return code") '’ trap invalid return codes...'
Exit Do
End Select
Loop Until status = EEndOfLogFile
status = rtdx.Close() '’ Close channel'
End Sub
nhưng khi chạy thì nó báo lỗi ở 2 dòng mình đã bôi đen....có bác nào biết cách fix thì chỉ dùm mình với
Chỉnh sửa lần cuối bởi điều hành viên: