技成培训网 技成学习APP 技成工具箱 技成企业服务

欢迎回到技成培训网

技成培训网

电工题库宝典

技成电工课堂

PLC练习题

技成PLC课堂

变频器故障查询

技成PLC学吧

伺服驱动故障查询

技成PLC网校

当前位置:技成首页 > 文章中心 > 技成百科 > 利用vbs实现msflexgrid控件的赋值

利用vbs实现msflexgrid控件的赋值

郑志武 发布于2012-12-10 23:03 6 0 标签:

在activex控件中添加了microsoftflexgridcontrol,version6.0控件,然后拖了一个到界面中,又拖了一个按钮,见图片1
wincc用的7.0,现在msflexgrid控件实现能实现历史数据做报表,现在基本的点击按钮变量在控件中显示实现不了。请大侠帮忙。

https://www.ad.siemens.com.cn/service/answer/solution.aspx?q_id=27738&cid=1032

https://www.ad.siemens.com.cn/club/bbs/post.aspx?b_id=5&a_id=312512&s_id=0&num=5#anch

参考了以上2处的程序,点击按钮后无任何反应。请教大侠帮忙

佳答案

给你一个例子,可以参考:
在界面上添加一msflexgrid1控件,命名为msflexgrid1
dimmsflexgrid1
setmsflexgrid1=screenitems("msflexgrid1")
dimstr2asstring
str2="字段一|字段二"
msflexgrid1.allowuserresizing=1
msflexgrid1.fixedrows=1
msflexgrid1.fixedcols=0
msflexgrid1.formatstring=str2
msflexgrid1.colwidth(0)=1600
msflexgrid1.colwidth(1)=2300
msflexgrid1.rows=1
msflexgrid1.cols=2
dimcnnasstring
cnn="provider=winccoledbprovider.1;catalog=cc_test_09_07_14_14_54_22r;datasource=计算机名wincc"
setcc1=createobject("adodb.connection")
cc1.connectionstring=cnn
cc1.cursorlocation=3
cc1.open
dimrstasobject
setrst=createobject("adodb.recordset")
dimssqlasstring
ssql="tag:r,'archive_testarchive_test1','"&"2009-8-1910:00:00.000','"&"2009-8-1910:59:59.999'"
rst.openssql,cc1
ifrst.recordcount=0then
msgbox"查无结果"
else
rst.movefirst
dowhilenotrst.eof
msflexgrid1.additem(rst.fields(1).value&vbtab&rst.fields(2).value)
rst.movenext
loop
cc1.close
setcc1=nothing
setrst=nothing
setmsflexgrid1=nothing

若有收获,就点个赞吧!

文章来源于网络及文献如有侵权请联系站长
分享到:

微信扫一扫分享

阅读与本文标签相同的文章

相关推荐

最新文章 热门文章
最新课程 免费课程
PLC资料下载 电工电气资料下载
应用新秀
变频器故障代码查询APP
伺服故障代码查询APP
技成
手机APP
热门标签