回复:作为对论坛得回报,贴上段代码,望大家不要见笑!!!

ucosii

  • 帖子

    209
  • 精华

    1
  • 被关注

    0

论坛等级:游士

注册时间:2005-08-23

普通 普通 如何晋级?

发布于 2006-07-23 22:20:15

0楼

如下
Dim cn , SqlCon, search_sql ,citems,row,listview,rscount,rCom(768)
Dim rs1,rs2,rs3
Dim search_sql1,search_sql2,search_sql3
Dim flag
Dim tagvalue,lbox1,lbox2
Set lbox1=ScreenItems("listbox1")
Set lbox2=ScreenItems("listbox2")
Dim pbar
Set pbar=ScreenItems("pbar")

Dim wendu,weishui,yali
wendu="\wendu"
weishui="\weishui"
yali="\yali"

Set cn=CreateObject("adodb.connection")
'Set rs=CreateObject("adodb.recordset")
Dim starData,starTime, endData,endTime
Dim dp1,dp2,dp3,dp4
Dim dpvalue1,dpvalue2,dpvalue3,dpvalue4
Set dp1=ScreenItems("dtpicker1")
dpvalue1=Left(dp1.Value,9)
Set dp2=ScreenItems("dtpicker2")
dpvalue2=Right(dp2.Value,8)
Set dp3=ScreenItems("dtpicker3")
dpvalue3=Left(dp3.Value ,9)
Set dp4=ScreenItems("dtpicker4")
dpvalue4=Right(dp4.Value,8)

Dim startdt,enddt
startdt=dpvalue1&" "&dpvalue2' qi shi shi jian jian zi fu chuan
enddt=dpvalue3&" "&dpvalue4 'jie shu shi jian zi fu chuan
'MsgBox "the startdata is : "&dpvalue1
'MsgBox "the enddata is:"&dpvalue3

SqlCon="Provider=WinCCOLEDBProvider;Catalog=CC_winccsingle-proj_06_07_23_09_19_11R;Data Source=.\WinCC"

cn.connectionstring=SqlCon
cn.Cursorlocation=3
cn.open


Set listview = ScreenItems("ListView1")
' xiang listview jia biao tou
Dim u
For u=1 To lbox2.listcount-1
If u=1 Then

With listview
.columnheaders.add,,"Date",90
End With
End If
With listview
.ColumnHeaders.add,,lbox2.list(u)&wendu,110
.ColumnHeaders.add,,lbox2.list(u)&weishui,110
.ColumnHeaders.add,,lbox2.list(u)&yali,110
End With
Next

Dim i,str,value
Dim rs(768),tag(768),query(768)

Dim count
Dim p
p=1
' kai shi jin ru xuan huan du qu shu ju ku
pbar.max=lbox2.listcount*3-3
For i=1 To lbox2.listcount-1

' du qu listbox de lie biao xiang
str=Right(lbox2.list(i),3)
If Left(str,1)="c" Then
value=Right(lbox2.list(i),1)
Else If Left(str,1)="e" Then
value=Right (lbox2.list(i),2)
Else
value=Right (lbox2.list(i),3)
End If
End If
'sheng cheng shu ju ji he
tag(p)="'Node"&value&"\Node"&value&"_temperature'"
tag(p+1)="'Node"&value&"\Node"&value&"_moisture'"

tag(p+2)="'Node"&value&"\Node"&value&"_pressure'"
query(p)="TAG:R,"&tag(p)&","&startdt&","&enddt&""
query(p+1)="TAG:R,"&tag(p+1)&","&startdt&","&enddt&""
query(p+2)="TAG:R,"&tag(p+2)&","&startdt&","&enddt&""
Set rCom(p)=CreateObject("ADODB.Command")
rCom(p).CommandType=1
Set rCom(p).ActiveConnection=cn

rCom(p).CommandText=query(p)
Set rs(p)=rCom(p).execute
'MsgBox "the recordcount is "&rs(p).recordcount
pbar.value=p
Set rCom(p+1)=CreateObject("ADODB.Command")
rCom(p+1).CommandType=1
Set rCom(p+1).ActiveConnection=cn

rCom(p+1).CommandText=query(p+1)
Set rs(p+1)=rCom(p+1).execute
pbar.Value=p+1


Set rCom(p+2)=CreateObject("ADODB.Command")
rCom(p+2).CommandType=1
Set rCom(p+2).ActiveConnection=cn
'rCom(p)="rCom"&p
rCom(p+2).CommandText=query(p+2)
Set rs(p+2)=rCom(p+2).execute
pbar.Value=p+2
count=count+1
p=p+3
Next
'MsgBox "the p is "&P
Dim ecount,t
ecount=lbox2.listcount*3' zan shi mei you shen m yong

MsgBox "Ready to fillful the the listview"
pbar.Value=0
MsgBox "the recordcount is "&rs(1).recordcount
If rs(1).recordcount=0 Then
MsgBox "no data find!!!!"
Else
pbar.Max=rs(1).recordcount
'MsgBox "the pbar.max is "&pbar.Max
End If
Dim xx 'gei progress bar yong kong zhi jing du tiao jing du
Do While Not rs(1).eof

Set citems=listview.listitems.add()
citems.Text=CStr(rs(1).fields(1).value)
pbar.Value=xx

For t=1 To 12' yi gong cai zu tai le 4 ge xia wei bianl iiang

citems.subitems(t)=CStr(rs(t).fields(2).value)


rs(t).movenext

next
xx=xx+1
Loop

'MsgBox "the xx is "&xx
xx=HMIRuntime.Tags("listview_count").Read
'MsgBox "the listview's row is "&listview.rows

Dim close
Set cn=Nothing
For close=1 To 256
Set rs(close)=Nothing
next

狭路相逢勇者胜
评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32889条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
X 图片
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。