Dim sPro,sDsn,sSer,sCon,conn,sSql,oRs,oCom
Dim tagDSNName
Dim m,i,j,k
Dim LocalBeginTime, LocalEndTime,UTCBeginTime, UTCEndTime,sVal
写下的英文
Dim objExcelApp,objExcelBook,objExcelSheet,sheetname,spreadsheet
item.Enabled = Fal
On Error Resume Next
sheetname="Sheet1"
Set spreadsheet = ScreenItems ("spreadsheet")
Dim fso,fso_ok,mode_file_name
mode_file_name = "D:\l" '模板存储位置
盘古开天地课文原文Set fso=CreateObject("Scripting.FileSystemObject")
喜什么厌什么
fso_ok=fso.FileExists(mode_file_name)
If fso_ok=0 Then
MsgBox "l file not exist!"
item.Enabled = True
Set fso=Nothing
徐右冰Exit Sub
End If
Set fso=Nothing
spreadsheet.XMLURL = mode_file_name
spreadsheet.Width = 1110 'spreadsheet控件宽度
spreadsheet.Height = 304 'spreadsheet控件高度
Set tagDSNName = HMIRuntime.Tags("@DatasourceNameRT")
tagDSNName.Read
Set LocalBeginTime = HMIRuntime.Tags("BTIME") '起始时间变量
LocalBeginTime.Read
Set LocalEndTime = HMIRuntime.Tags("ETIME") '中止时间变量
LocalEndTime.Read
UTCBeginTime = DateAdd("h" ,-8,LocalBeginTime.Value)
UTCEndTime = DateAdd("h" ,-8,LocalEndTime.Value)
Dim str,con,sql
sPro = "Provider=WinCCOLEDBProvider.1;"
sDsn = "Catalog=" &tagDSNName.Value& ";"
sSer = "Data Source=LSQ\WinCC"
sCon = sPro + sDsn + sSer
Set con=CreateObject("ADODB.Connection")
con.ConnectionString = sCon
con.CursorLocation = 3
con.Open
j = 1
Do While j<10 '10=查询归档变量数量+1
If j=1 Then
sql = "Tag:R,('R\R1'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'" '3600秒查询间隔
End If
If j=2 Then
sql = "Tag:R,('R\R2'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
If j=3 Then
sql = "Tag:R,('R\R3'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
If j=4 Then
sql = "Tag:R,('R\R4'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
If j=5 Then
sql = "Tag:R,('R\R5'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
守护明天观后感
If j=6 Then
sql = "Tag:R,('R\R6'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
If j=7 Then
sql = "Tag:R,('R\R7'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
If j=8 Then
冬则温sql = "Tag:R,('R\R8'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
If j=9 Then
sql = "Tag:R,('R\R9'),'" & UTCBeginTime & "','" & UTCEndTime & "','TIMESTEP=3600,1'"
End If
Set oRs = CreateObject("ADODB.Recordt")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = con
oCom.CommandText = sql
Set oRs = oCom.Execute
m = oRs.RecordCount
If (m > 0) Then
oRs.MoveFirst
Dim s,t
s=5 ''时间行
t=5 ''数据行
i=5 ''循环
k=j+1
Do While Not oRs.EOF '是否到记录末尾,循环填写表格
If j=1 Then
oRs.Fields(1).Value) '写入时间变量
s=s+1
End If
t=t+1
oRs.MoveNext
i=i+1
Loop
oRs.Clo
El
MsgBox "No data……"
item.Enabled = True
Set oRs = Nothing
con.Clo
Set con = Nothing
Exit Sub
End If
j=j+1
Loop幼儿园培训心得体会
'释放资源
小学生评语
Set oRs = Nothing
con.Clo
Set con = Nothing
MsgBox "Create Data successful!"
item.Enabled = True