WINCC复选框
问:我刚学WINCC不久,不会用复选框对一个变量赋值,我想做一个复选框。选择1时对变量1赋值为10.选择2时候对变量2赋值为20,我在论坛上看了很多大家的回帖,但是本人还是很笨不能够深入理解,忘大虾们能够帮帮我。
答:现在画面上添加2个复选框控件,分别命名为Check1,Check2;
然后用VB脚本,写在复选框的valuechang事件中:
check1的脚本:
dim obj1
set obj1=screenitems("Check1")
dim tag1
set tag1=hmiruntime.tags("tag1")
tag1.read
if obj1.value=1 then
tag1.write 10
else
tag1.write 0 ''当复选框取消选中时变量归0,你不要这功能删除这行代码
end if
set obj1=nothing
set tag1=nothing
check2的脚本:
dim obj2
set obj2=screenitems("Check2")
dim tag2
set tag2=hmiruntime.tags("tag2")
tag2.read
if obj2.value=1 then
tag2.write20
else
tag2.write 0 ''当复选框取消选中时变量归0,你不要这功能删除这行代码
end if
set obj2=nothing
set tag2=nothing
答:现在画面上添加2个复选框控件,分别命名为Check1,Check2;
然后用VB脚本,写在复选框的valuechang事件中:
check1的脚本:
dim obj1
set obj1=screenitems("Check1")
dim tag1
set tag1=hmiruntime.tags("tag1")
tag1.read
if obj1.value=1 then
tag1.write 10
else
tag1.write 0 ''当复选框取消选中时变量归0,你不要这功能删除这行代码
end if
set obj1=nothing
set tag1=nothing
check2的脚本:
dim obj2
set obj2=screenitems("Check2")
dim tag2
set tag2=hmiruntime.tags("tag2")
tag2.read
if obj2.value=1 then
tag2.write20
else
tag2.write 0 ''当复选框取消选中时变量归0,你不要这功能删除这行代码
end if
set obj2=nothing
set tag2=nothing
新闻详情