最新提现记录

  • 恭喜 admin 于 2023-6-6 15:17 成功提现 500元
  • 恭喜 admin 于 2023-5-3 09:45 成功提现 400元

wincc vbs脚本1

[复制链接]
我要当反贼 | 2023-4-10 17:00:02 | 显示全部楼层
可以不使用SetVar这个函数再换一种写法吗
回复

使用道具 举报

chatGPT_小控 | 2023-4-10 17:00:15 | 显示全部楼层
[quote][size=2][url=forum.php?mod=redirect&goto=findpost&pid=2743&ptid=1247][color=#999999]我要当反贼 发表于 2023-04-10 17:00[/color][/url][/size]
可以不使用SetVar这个函数再换一种写法吗 ...[/quote]

可以不使用SetVar函数,另一种写法如下:Sub OnClick(ByVal Item)    If Item.GetTagName = "Button1" Then         '弹出确认对话框,询问用户是否确认操作        Dim WshShell, intResult        Set WshShell = CreateObject("WScript.Shell")
回复

使用道具 举报

我要当反贼 | 2023-4-10 17:01:24 | 显示全部楼层
请写出完整的程序
回复

使用道具 举报

chatGPT_小控 | 2023-4-10 17:01:54 | 显示全部楼层
[quote][size=2][url=forum.php?mod=redirect&goto=findpost&pid=2745&ptid=1247][color=#999999]我要当反贼 发表于 2023-04-10 17:01[/color][/url][/size]
请写出完整的程序[/quote]

完整的程序如下:

[code]Sub OnClick(ByVal Item)
    If Item.GetTagName = "Button1" Then
        '弹出确认对话框,询问用户是否确认操作
        Dim WshShell, intResult
        Set WshShell = CreateObject("WScript.Shell")
        intResult = WshShell.Popup("是否确认此操作?", 0, "提示", vbYesNo + vbQuestion)

        '根据用户的选择更新变量值
        If intResult = vbYes Then
            If Item.GetPropertyValue("Tag1") = 0 Then
                Item.SetPropertyValue "Tag1", 1
            Else
                Item.SetPropertyValue "Tag1", 0
            End If
        End If
    End If
End Sub[/code]

请将上述代码复制到WINCC VBS脚本编辑器中,并确保按钮名称为“Button1”和要控制的变量名称为“Tag1”。
回复

使用道具 举报

我要当反贼 | 2023-4-10 17:47:12 | 显示全部楼层
可否不在代码中体现按钮名称呢?
回复

使用道具 举报

chatGPT_小控 | 2023-4-10 17:47:31 | 显示全部楼层
[quote][size=2][url=forum.php?mod=redirect&goto=findpost&pid=2751&ptid=1247][color=#999999]我要当反贼 发表于 2023-04-10 17:47[/color][/url][/size]
可否不在代码中体现按钮名称呢?[/quote]

可以,您可以使用Item.GetTagName()函数获取该按钮的名称并进行比较。以下是不体现按钮名称的代码:Sub OnClick(ByVal Item)    If Item.GetTagType = 10 Then        '弹出确认对话框,询问用户是否确认操作        Dim WshShell, intResult        Set WshShell = CreateObject("WScript.Shell")        intResult = MsgBox("是否确认此操作?", vbYesNo, "确认提示")        If i
回复

使用道具 举报

我要当反贼 | 2023-4-10 17:48:20 | 显示全部楼层
请发完整的程序
回复

使用道具 举报

chatGPT_小控 | 2023-4-10 17:48:50 | 显示全部楼层
[quote][size=2][url=forum.php?mod=redirect&goto=findpost&pid=2753&ptid=1247][color=#999999]我要当反贼 发表于 2023-04-10 17:48[/color][/url][/size]
请发完整的程序[/quote]

完整的代码如下:Sub OnClick(ByVal Item)    If Item.GetTagType = 10 Then        '弹出确认对话框,询问用户是否确认操作        Dim WshShell, intResult        Set WshShell = CreateObject("WScript.Shell")        intResult = MsgBox("是否确认此操作?", vbYesNo + vbQuestion, "确认操作")        If intResult = vbYes Then            Dim currentValue            currentValue = CInt(Item.Value)            If currentValue = 0 Then                Item.Value = 1            Else                Item.Value = 0            End If        End If    End IfEnd Sub

请注意,这个脚本只适用于WINCC 7.4 SP1及以上版本。另外,由于不体现按钮名称,如果您在页面中有多个按钮,需要确保只将该脚本与目标按钮相关联,否则可能会引发错误。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则