VB6.0高手帮忙看看,下标越界,程序哪里有问题。
' *
' * (c) Copyright 1997 Yokogawa Electric Corporation
' *
' * system : CS1000
' * sub-system : HIS
' * description : OCX sample
' *
Option Explicit
Option Base 0
Const MaxTagItems = 37& ' Number of tag name - 1
'
' Get process data
'
Private Sub cmdGetData_Click()
Dim TagItems(MaxTagItems) As String ' TagNames
Dim i As Integer ' Work
Dim Values As Variant ' Process value
' Set up item information
TagItems(0) = "LRCA1101.PV"
TagItems(1) = "PRA1714.PV"
TagItems(2) = "LRA1715.PV"
TagItems(3) = "TR1734.PV"
TagItems(4) = "PRA8101A.PV"
TagItems(5) = "LRA8101A.PV"
TagItems(6) = "TRA8101A.PV"
TagItems(7) = "PRA8101B.PV"
TagItems(8) = "LRA8101B.PV"
TagItems(9) = "TRA8101B.PV"
TagItems(10) = "PRA8101C.PV"
TagItems(11) = "LRA8101C.PV"
TagItems(12) = "TRA8101C.PV"
TagItems(13) = "PRA8101D.PV"
TagItems(14) = "LRA8101D.PV"
TagItems(15) = "TRA8101D.PV"
TagItems(16) = "PRA8101E.PV"
TagItems(17) = "LRA8101E.PV"
TagItems(18) = "TRA8101E.PV"
TagItems(19) = "PRA8101F.PV"
TagItems(20) = "LRA8101F.PV"
TagItems(21) = "TRA8101F.PV"
TagItems(22) = "PRA8101G.PV"
TagItems(23) = "LRA8101G.PV"
TagItems(24) = "TRA8101G.PV"
TagItems(25) = "PRA8102.PV"
TagItems(26) = "LRA8102.PV"
TagItems(27) = "TRA8102.PV"
TagItems(28) = "PRA8103.PV"
TagItems(29) = "LRA8103.PV"
TagItems(30) = "TRA8103.PV"
TagItems(31) = "PRA8104.PV"
TagItems(32) = "LRA8104.PV"
TagItems(33) = "TRA8104.PV"
TagItems(34) = "PRA8105.PV"
TagItems(35) = "LRA8105.PV"
TagItems(36) = "TRA8105.PV"
' Get process data
CENTUM1.StationName = txtHostName
CENTUM1.GetTagQuality = False
CENTUM1.Transpose = False
Values = CENTUM1.GetTagData(TagItems)
' Write process data
data1.Recordset.Update
data1.Recordset("LRCA1101") = Values(0)
data1.Recordset("PRA1714") = Values(1)
data1.Recordset("LRA1715") = Values(2)
data1.Recordset("TR1734") = Values(3)
data1.Recordset("PRA8101A") = Values(4)
data1.Recordset("LRA8101A") = Values(5)
data1.Recordset("TRA8101A") = Values(6)
data1.Recordset("PRA8101B") = Values(7)
data1.Recordset("LRA8101B") = Values(8)
data1.Recordset("TRA8101B") = Values(9)
data1.Recordset("PRA8101C") = Values(10)
data1.Recordset("LRA8101C") = Values(11)
data1.Recordset("TRA8101C") = Values(12)
data1.Recordset("PRA8101D") = Values(13)
data1.Recordset("LRA8101D") = Values(14)
data1.Recordset("TRA8101D") = Values(15)
data1.Recordset("PRA8101E") = Values(16)
data1.Recordset("LRA8101E") = Values(17)
data1.Recordset("TRA8101E") = Values(18)
data1.Recordset("PRA8101F") = Values(19)
data1.Recordset("LRA8101F") = Values(20)
data1.Recordset("TRA8101F") = Values(21)
data1.Recordset("PRA8101G") = Values(22)
data1.Recordset("LRA8101G") = Values(23)
data1.Recordset("TRA8101G") = Values(24)
data1.Recordset("PRA8102") = Values(25)
data1.Recordset("LRA8102") = Values(26)
data1.Recordset("TRA8102") = Values(27)
data1.Recordset("PRA8103") = Values(28)
data1.Recordset("LRA8103") = Values(29)
data1.Recordset("TRA8103") = Values(30)
data1.Recordset("PRA8104") = Values(31)
data1.Recordset("LRA8104") = Values(32)
data1.Recordset("TRA8104") = Values(33)
data1.Recordset("PRA8105") = Values(34)
data1.Recordset("LRA8105") = Values(35)
data1.Recordset("TRA8105") = Values(36)
Exit Sub
' Error exit
ERR_EXIT:
MsgBox "ERROR"
End Sub
Private Sub cmdStopData_Click()
tmr = False
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
tmr = True
End Sub
Private Sub Label10_Click()
End Sub
Private Sub tmr_Timer()
cmdGetData.Value = True
End Sub
Private Sub Timer1_Timer()
cmdGetData.Value = True
End Sub