how to change items property in winnc tia portal using vbscript

Published on Dec27, 2024 | Category: wincc tia
Share this article:

items like button, circle, text field, label gauge, slider guage have property like color, border, style, fontcolor, apperance, visibility, enable or disable items. in vbscript these property also changed when particular event triggerd. in this article we have basic example to change some property like visibility, background color change, enable or disable, change background, border and font color. this property are easily changed with vbscript. vbscript is very simple language to learn and understand.

tia portal wincc vbscript to change background color

in this example we see how to back ground color change when button is pressed or when value of inputoutput field reached to maximum value. in this article we change back ground color of circle and input output field text color for a particular values. to do this add component circle and input output filed to screen. add a tag input1 in tag table so we read tag value in vbscript. add input1 tag for i/o field in tag property.

img/wincc tia vbscript for items/tia portal wincc vbscript to change background color.webp

below is the example of This VBScript. compile this script and add this script to i/o field input finished event property. subroutine named VBFunction_1 designed to dynamically update the properties of graphical elements on an HMI screen based on the value of a tag named input1. Below is a detailed explanation of vbscript

The script uses conditional statements to change the colors of the screen elements based on the value of iofieldvalue:

img/wincc tia vbscript for items/tia portal wincc vbscript to change background color example.webp

wincc vbscript to enable or disable screen items

in this vbscript disable button and i/o field when i/o field value is greater than 50. so first add two button, i/o field and declare input1 tag to i/o field. logic is very simple if i/o field value is greater than 50 then button1 and i/o field disable. if component is disable then we can't change state or input. for enabling button1 and i/o field add press second button.

img/wincc tia vbscript for items/wincc vbscript to enable or disable screen items.webp

above is example wincc vbscript to enable or disable screen items. add this subroutine to i/o field input finished event and button pressed event property. and also in button press event set a function to set value of input1 tag to 0. following are the explanation below vbscript example.

img/wincc tia vbscript for items/wincc vbscript to enable or disable screen items example.webp

wincc vbscript to change text of items

in this example we change a text of text filed when i/o field value is changed. add i/o field and set input1 tag to i/o field. add a test field, than create a vbscript. add this vbscript to i/o field input finished event property.

img/wincc tia vbscript for items/wincc vbscript to change text of items.webp

above is the example of wincc vbscript to change text of items. when i/o field value changed than same value with predefined text set to text field.

img/wincc tia vbscript for items/wincc vbscript to change text of items example.webp

wincc vbscript to increment and decrement radius of items

in this vbscript we understand how to change radius of an wincc hmi items using vbscript. so add a circle, and two button on button used for increment and second button is used for decrement. now create a two vb script first script increment radius of circle by 10 and second vbscript decrement circle radius by 10. after compile both script add these two script in button pressed event property.

img/wincc tia vbscript for items/wincc vbscript to increment and decrement radius of items.webp

now we have two script increment script and decrement script. when increment button is pressed then circle radius increment by 10 and if the decrement button is pressed than circle radius decrement by 10. you can also change height, width, border width border color etc.