VBS代码实现按下1松开0

已锁定

spring1234

  • 帖子

    120
  • 精华

    1
  • 被关注

    8

论坛等级:侠士

注册时间:2008-09-28

普通 普通 如何晋级?

VBS代码实现按下1松开0

1656

1

2012-10-15 17:46:23

一个新手编的2个按钮代码: 第一个按钮按下去后出现小画面,再按第二个按钮,给B赋1;松开0;
第一个按钮:
Dim motor_command_req
Set motor_command_req=HMIRuntime.Tags("motor_command_req_1")
motor_command_req.Write "B"

第二个按钮按下去:
Sub OnLButtonDown(Byval Item, Byval Flags, Byval x, Byval y)

Dim motor_command_req_1
Set motor_command_req_1=HMIRuntime.Tags("motor_command_req_1")

Dim motor_1
Set motor_1=HMIRuntime.Tags(motor_command_req_1.read)
motor_1.Write 1
End Sub

第二个按钮松开:
Sub OnLButtonUp(Byval Item, Byval Flags, Byval x, Byval y)

Dim motor_command_req_1
Set motor_command_req_1=HMIRuntime.Tags("motor_command_req_1")

Dim motor
Set motor=HMIRuntime.Tags(motor_command_req_1.read)
motor.Write 0
End Sub
其中motor_command_req_1 为WINCC内部变量;B是写给PLC的变量;
按下第一个按钮后,再按第二个按钮实现给PLC变量B赋值1;松开B赋值0;
请大侠分析下:
1.第一个按钮的代码起什么作用??最终的目的是给PLC 的B变量写值,为什么把B写给motor_command_req_1???? 在我看来应该是
SET motor_command_req_1=HMIRuntime.Tags("B")
motor_command_req_1.Write " motor_command_req_1"
2. Dim motor_command_req_1
Set motor_command_req_1=HMIRuntime.Tags("motor_command_req_1")
这2行起啥作用??
Dim motor
Set motor=HMIRuntime.Tags(motor_command_req_1.read)
motor.Write 0
这3行起啥作用???
VBS代码实现按下1松开0 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC WinCC / Panel

共有32670条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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