wincc的变量赋值

哪位老师能帮我解决以下问题:
  1、在项目中有“Taga”、“Tagb”、“Tag1”、“Tag2”、“Tag3”外部变量。
  2、当按下按钮时执行:
   当Taga数值=1时,把Tag1的值写入Tagb;
   当Taga数值=2时,把Tag2的值写入Tagb;
   当Taga数值=3时,把Tag3的值写入Tagb;
3、按钮和变量配置没问题,我用VBS脚本写了几次运行不正确。
    哪位老师能帮我写一下?
 谢谢!不胜感激!

问题补充:
最好使用vb脚本。谢谢!

最佳答案

dim a
dim b
dim x
dim x1
dim x2
dim x3
set a = hmiruntime.tages("taga")
a.read
set b = hmiruntime.tages("tagb")
b.read
set x1 = hmiruntime.tages("tag1")
x1.read
set x2 = hmiruntime.tages("tag2")
x2.read
set x3 = hmiruntime.tages("tag3")
x3.read

if a.value=1 then
x=x1.value
b.write x
end if
if a.value=2 then
x=x2.value
b.write x
end if
if a.value=3 then
x=x3.value
b.write x
end if

提问者对于答案的评价:
非常感谢塞上雁老师和mugui老师!
这两位老师的答案我已运行过,很好用,两位老师的回答采用了两种方法,使我受益匪浅,但答案只能采纳一位老师的。
mugui老师的答案在倒数第五行编译时改为“End Select”后,运行正常。
再次感谢两位老师花掉时间对我的帮助!
同时感谢其它的热心答侠,祝我们栏目越办越好!

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc268278.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2019年6月11日
下一篇 2019年6月11日

相关推荐