VB与wincc通讯读写变量部分源码,请下载、参考!

已锁定

kwg007

  • 帖子

    187
  • 精华

    2
  • 被关注

    2

论坛等级:游侠

注册时间:2003-06-06

普通 普通 如何晋级?

VB与wincc通讯读写变量部分源码,请下载、参考!

4760

10

2005-09-12 15:36:19

一工程为方便用户查询,我用VB作一小程序读写WINCC变量存入数据库中,部分源码如下,请各位赐教:

Private Sub Form_Load()

Dim b, var1_16, c As Variant

Data1.DatabaseName = App.Path + "\db1.mdb"
DBGrid1.Caption = "本 系 统 操 作 记 录"

Data1.RecordSource = "Select* from 表1 Order By 时间"
Data1.Refresh
Text1.Text = Data1.Recordset.RecordCount

Command2.Picture = LoadPicture(App.Path + "\recv.ico")
Command4.Picture = LoadPicture(App.Path + "\table.ico")
Command1.Picture = LoadPicture(App.Path + "\book04.ico")
Command6.Picture = LoadPicture(App.Path + "\state31.ico")
Picture1.Picture = LoadPicture(App.Path + "\W95MBX03.ico")
DTPicker3.Value = Date
DTPicker4.Value = Date


Set mcp = CreateObject("WinCC-Runtime-Project")


first_1 = mcp.GetValue("man_var_1_16")
first_2 = mcp.GetValue("man_var_17_24_m")
first_3 = mcp.GetValue("man_xitong")
first_4 = mcp.GetValue("man_box")
first_11 = mcp.GetValue("var_zhuangtai_1-16_o") '读1-16号阀开状态
first_12 = mcp.GetValue("var_zhuangtai_17-24_o") '读17-24号阀开状态
first_13 = mcp.GetValue("var_zhuangtai_1-16_c") '读1-16号阀关状态
first_14 = mcp.GetValue("var_zhuangtai_17-24_c") '读17-24号阀关状态
first_15 = mcp.GetValue("zhuangtai_fs") '其他

DBGrid1.Columns(0).Alignment = 2 '居中对齐
DBGrid1.Columns(1).Alignment = 2 '居中对齐



End Sub

Private Sub Timer1_Timer() '添加过滤记录

Dim xianshi As Variant
Dim tuichu As Variant
xianshi = "记录显示"
tuichu = "记录退出"

If mcp.GetValue(xianshi) = 1 Then
bRet = mcp.SetValue(xianshi, 0)
Form1.Visible = True

Exit Sub
End If



If mcp.GetValue(tuichu) = 1 Then

bRet = mcp.SetValue(tuichu, 0)
Unload Form1
End If


If Hour(Now) = 12 And Second(Now) = 0 And Minute(Now) = 0 Then

Set db = DBEngine.OpenDatabase(App.Path + "\db1.mdb")

i = Now - 20

db.Execute "delete*from 表3 where 时间 < # " & i & " #"
db.Execute "delete*from 表2 where 时间 < # " & i & " #"
db.Execute "delete*from 表1 where 时间 < # " & i & " #"

End If


End Sub
VB与wincc通讯读写变量部分源码,请下载、参考! 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32644条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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