WINCC中組合框的使用

2022-07-07 02:54:07 字數 3569 閱讀 9616

通過組合框切換當前介面。

sub onobjectchanged(byval item)           

if item.selindex = 1 then

hmiruntime.basescreenname = "monitor1-0"

end if

if item.selindex = 2 then

hmiruntime.basescreenname = "monitor2-0"

end if

if item.selindex = 3 then

hmiruntime.basescreenname = "monitor1-1"

end if

if item.selindex = 4 then

hmiruntime.basescreenname = "monitor1-2"

end if

if item.selindex = 5 then

hmiruntime.basescreenname = "monitor1-3"

end if

if item.selindex = 6 then

hmiruntime.basescreenname = "monitor1-4"

end if

if item.selindex = 7 then

hmiruntime.basescreenname = "monitor2-1"

end if

if item.selindex = 8 then

hmiruntime.basescreenname = "monitor2-2"

end if

if item.selindex = 9 then

hmiruntime.basescreenname = "monitor2-3"

end if

if item.selindex = 10 then

hmiruntime.basescreenname = "monitor2-4"

end if

end sub

通過組合框選擇給內部變數comboxindex變數賦值

sub onobjectchanged(byval item)   

if item.selindex =1 then

hmiruntime.tags("comboxindex").write "1"

end if

if item.selindex =2 then

hmiruntime.tags("comboxindex").write "2"

end if

if item.selindex =3 then

hmiruntime.tags("comboxindex").write "3"

end if

msgbox hmiruntime.tags("comboxindex").value            訊息盒子

end sub

組合框改變畫面視窗

sub onobjectchanged(byval item)                        

dim objpicwindow

'msgbox "ready"

set objpicwindow = screenitems("畫面視窗1")

'msgbox "ok"

'objpicwindow.screenname = "pic2"

'msgbox "really?"     

if item.selindex = 1 then

objpicwindow.screenname = "picinpic1"

end if

if item.selindex = 2 then

objpicwindow.screenname ="picinpic2"

end if

if item.selindex = 3 then

objpicwindow.screenname ="picinpic3"

end if

'msgbox hmiruntime.tags("comboxindex").value 

end sub

別人程式:

dim nownum

dim tagprefix

on error resume next   '遇到錯誤自動跳轉到下一行,防止畫面其他的腳步被卡死

nownum = hmiruntime.tags("nowpicturenum").read  '讀取記憶體變數值

if (nownum < 1)or (nownum >20) then             '容錯處理

hmiruntime.tags("nowpicturenum").write 1

nownum = 1

end if

tagprefix = "ahu" & nownum

screenitems("mod").tagprefix = tagprefix        '定義畫面上的畫面視窗[mod]的變數字首為ahu1~ahu20

select case nownum

case 1,2,3,4,5,8                      '當記憶體變數值為1~5,8 時[mod]的畫面名稱為ahumod01

screenitems("mod").screenname = "ahumod01"

case 10                                      '當記憶體變數值為10 時[mod]的畫面名稱為ahumod02

screenitems("mod").screenname = "ahumod02"

case 6,7,11,12                              '當記憶體變數值為6,7,11,12時[mod]的畫面名稱為ahumod03

screenitems("mod").screenname = "ahumod03"

case 13,14

screenitems("mod").screenname = "ahumod04"

case 15,16,17,18

screenitems("mod").screenname = "ahumod05"

case else                              '當記憶體變數值不為上述值時[mod]的畫面名稱為ahumod06

screenitems("mod").screenname = "ahumod06"

end select

**的作用就是:

把當前畫面上,名稱為[mod]的畫面視窗控制項的變數字首根據記憶體變數nowpicturenum的值賦值為"ahu1"~"ahu12",把畫面名稱

賦值為"ahumod01"~"ahumod06"。

也就是你說的,通過改變記憶體變數nowpicturenum的值,從而使[mod]呼叫不同的模版"ahumod01"~"ahumod06"。

上面的**是wincc的vbs**,希望你看得懂吧。

要使用上面的**,先在視窗拖放乙個[矩形]控制項,並且把[矩形]控制項的"啟用閃爍背景"屬性設定為'是',再到[矩形]控制項的"其他"-"物件改變"事件裡面新增上述的vbs指令碼。

C 列表框 複選列表框 組合框的使用

功能實現效果 實現 1 宣告相關變數儲存專業 課程設定及相關資訊 csharp string gr,msg,xy string spec,cour1,cour2,cour3,cour4,cour5 2 在form1類中自定義函式bool checkgr 檢查學生資訊 csharp private b...

對話方塊中新增組合框的應用

1 在對話方塊中新增組合框控制項 2 在對話方塊中對組合框進行初始化,方法如下 這一工作在組合框屬性對話方塊上的data頁面上完成,如圖1所示。需要注意的是,在data頁面的列表框中,若想給組合框增加新的列表項,必須使用ctrl enter鍵才能回車到下一行增加新的列。該組合框在程式執行的時候也不允...

基本控制項使用例項 使用組合框控制項

窗體上建立兩個組合框控制項,分別設定組合框的dropdownstyle屬性,上面為dropdown型別,下面為dropdownlist型別。這兩種型別呈現的效果完全一樣,但是dropdown型別是可以讀寫的,但是dropdownlist型別僅僅為唯讀狀態,不可編輯。dropdownstyle還有乙個...