想在wincc窗口中调用ComboBox控件,此控件从SQL数据库读取值,每次修改后,重新刷新一遍。程序如下:
strSQL = "select name from usermanger where id<9 order by id"
Set objCommand = CreateObject("ADODB.Command")
With objCommand
.ActiveConnectioN = cn
.CommandTexT = strSQL
End With
Set objRecordset = objCommand.Execute
Set cboComboBox = HMIRuntime.Screens("Operation_window").ScreenItems("Control2").ObjectName
If cboComboBox Is Nothing Then
Exit Sub
End If
cboComboBox.Clear
Do While Not objRecordset.eof
cboCombobox.AddItem objRecordset.Fields(0).Value
objRecordset.movenext
Loop
完成后,运行画面报错如下:
Picture :operation_window.dpl_Events
Function :sub FillOperator
Line :28
Error :get_item:The Parameter is incorrect
请各位大虾指点,谢谢!
最佳答案
代码不全,不过从从你的描述中看出些许端倪,VBS访问画面窗口中的对象需要使用如下办法:
dim cboComboBox
Set cboComboBox = HMIRuntime.Screens("BaseScreenName.ScreenWindow:ScreenName").ScreenItems("Control2")
其中:BaseScreenName为主画面名称
ScreenWindow为画面窗口控件名称
ScreenName为子画面名称
提问者对于答案的评价:
谢谢,问题已解决!
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc273168.html