我正在尝试根据对 PIDataLink 当前值函数提供的特定值的更改将一系列有序值打印到当前工作表。我已将产生不匹配错误的区域加粗,意识到我的其余代码将共享此错误。(如果 MFA = "culstop" 则) *为了节省空间,缺少一些重复代码。
Sub culturestop_timestamp()
Dim culstop As String
Dim MFA As Variant
Dim MFA2 As String
Dim MFB As Variant
Dim MFC As Variant
Dim MFD As Variant
Dim MFE As Variant
Dim MFF As Variant
Dim MFG As Variant
Dim MFH As Variant
Dim start As Date
Dim curtime As Date
Dim rownum As Integer
Application.OnTime Now, "culturestop_timestamp"
reset:
'Application.OnTime TimeValue("00:00:00", "culturestop_timestamp")
start = Now()
rownum = 30
A = 0
B = 0
C = 0
D = 0
E = 0
F = 0
G = 0
H = 0
Do While curtime <= TimeValue("23:59:00")
Application.Wait (Now + TimeValue("00:00:30"))
MFA = Application.Run("PICurrVal", "TAPS1.MNFERMA_UNIT / PHASE_SELECT.CVS", 0, "")
MFB = Application.Run("PICurrVal", "TAPS1.MNFERMB_UNIT / PHASE_SELECT.CVS", 0, "")
MFC = Application.Run("PICurrVal", "TAPS1.MNFERMC_UNIT / PHASE_SELECT.CVS", 0, "")
MFD = Application.Run("PICurrVal", "TAPS1.MNFERMD_UNIT / PHASE_SELECT.CVS", 0, "")
MFE = Application.Run("PICurrVal", "TAPS1.MNFERME_UNIT / PHASE_SELECT.CVS", 0, "")
MFF = Application.Run("PICurrVal", "TAPS1.MNFERMF_UNIT / PHASE_SELECT.CVS", 0, "")
MFG = Application.Run("PICurrVal", "TAPS1.MNFERMG_UNIT / PHASE_SELECT.CVS", 0, "")
MFH = Application.Run("PICurrVal", "TAPS1.MNFERMH_UNIT / PHASE_SELECT.CVS", 0, "")
If A = 2 Then
MFA = "Already_Brothed_Out_Today"
End If
If B = 2 Then
MFB = "Already_Brothed_Out_Today"
End If
If C = 2 Then
MFC = "Already_Brothed_Out_Today"
End If
If D = 2 Then
MFD = "Already_Brothed_Out_Today"
End If
If E = 2 Then
MFE = "Already_Brothed_Out_Today"
End If
If F = 2 Then
MFF = "Already_Brothed_Out_Today"
End If
If G = 2 Then
MFG = "Already_Brothed_Out_Today"
End If
If H = 2 Then
MFH = "Already_Brothed_Out_Today"
End If
***If MFA = "culstop" Then***
A = 2
MFAR = Application.Run("PICurrVal", "TAPS1.TC02_RECIPE / MNFERMA_TYPE.CV", 0, "")
MFAT = Now()
Sheet1.Range("A" & rownum) = MFAT
Sheet1.Range("B" & rownum) = MFAR
'Sheet1.Range("C" & rownum) =
'Sheet1.Range("D" & rownum) =
'Sheet1.Range("E" & rownum) =
'Sheet1.Range("F" & rownum) =
rownum = rownum + 1
End If
If MFB = "culstop" Then
B = 2
MFBR = Application.Run("PICurrVal", "TAPS1.TC02_RECIPE / MNFERMB_TYPE.CV", 0, "")
MFBT = Now()
Sheet1.Range("A" & rownum) = MFBT
Sheet1.Range("B" & rownum) = MFBR
'Sheet1.Range("C" & rownum) =
'Sheet1.Range("D" & rownum) =
'Sheet1.Range("E" & rownum) =
'Sheet1.Range("F" & rownum) =
rownum = rownum + 1
End If
curtime = Now()
Loop
GoTo reset
End Sub