Depending on the status of a variable, a specific layer of a picture must be shown.
For this you can use the VBS script below, in which you only have to change the picture name, the layer, the variable and its value (for example, in a global VBS script or in a VBS action of an event of a button etc.).
This script functions only if the relevant screen is also open.
Set scrObj = HMIRuntime.Screens("@Screen.@win12:@1001.@Desk:Picture name")
Set Tag = HMIRuntime.Tags("Variable")
If Tag.Value = 0 Then
scrObj.Layers(Layer).Visible = False
scrObj.Layers(layer).Visible = True
Note (taken from the WinCC Online Help)
Upon access, the layers are counted in VBS starting with 1. Thus layer "0" in the WinCC Graphics Designer must be addressed with layers(1).
For example, if you want to address layer 10 in a screen,you must enter 11 for
If you have opened a screen on anther monitor, you must address it accordingly, "@Screen.@win22:@1001.@Desk:screenname", for example. More information about the addressing of different monitors is available in Entry ID: 831486.