vbscript

hkazan

Member
Join Date
Jan 2021
Location
lebanon
Posts
12
hello,

i m trying to write a VB script on wincc RT Advanced to activate an internal tag. but it won't work. any help here.

------------------------------

this is the script :

Sub VBFunction_1()

Dim AlarSet,Tsp,Psp,Ptsp,Fsp
Dim Tspv,Pspv,Ptspv,Fspv

Do While AlarSet = True

AlarSet = SmartTags("Alarms_settings")
Tsp = SmartTags("Tank SP")
Psp = HmiRuntime.SmartTags("Pump SP")
Ptsp = HmiRuntime.SmartTags("P.Temp Sp")
Fsp = HmiRuntime.SmartTags("Furance SP")

If Tsp = True Then
Tspv = True
Else
Tspv = False
End If

SmartTags("Tank_SP_View")= Tspv

Loop

End Sub
----------------------------

i activated the vbscript on a button properites/events/activate as shown in the picture below.

-------------------------------

Note: I declared more variables the code is bigger than this but i m trying on one tag now to make sure its working before i continue my code.

thx

Capture.JPG
 
I dont know what you are trying to achieve, but VBS is not suitable to be used in that way.

This line
Code:
Do While AlarSet = True
will freeze the VBS system for as long as AlarSet is true.

Also this
Code:
If Tsp = True Then
Tspv = True
Else
Tspv = False
End If
Can be written as this
Code:
Tspv = Tsp
It does not indicate a good understanding of the language.

I have a feeling that you want to program functionality in VBS that is better done by using the integrated functions in the panel.
 
I have a screen that display multi functionality as shown in the pic above, in one of these functionalities (alarm settings) I need to show multiple i/o fields.
the point is that when AlarSet tag and Tsp tag for example are true , Tspv tag should become true. which I use in the visibility option for that i/o field.
I can't use two tags in the visibility option for the same object on the screen, so i have to write a vbscript.
 
I solved it.
I used the sytemalram function to see whether the vbs is starting properly, the solution was to set the vb function on the release option of the bottom.
the click option set AlarSet to true, and the release option starts the vbs.
Thanks
 
the point is that when AlarSet tag and Tsp tag for example are true , Tspv tag should become true. which I use in the visibility option for that i/o field.
I can't use two tags in the visibility option for the same object on the screen, so i have to write a vbscript.
No, you code this easily in the PLC on a new tag. This PLC tag then enables the visualisation on the HMI.

Essentially, there should be no 'code' on the HMI, no matter that the code is for controlling the HMI. The HMI shall be controlled by the PLC. Buttons and IO fields should be connected directly to PLC tags. Any logic code should be done in the PLC.
 
yes I know that coding it on the PLC is easier I have done it before but on this task I wanted it to be on the HMI, its not about what the i/o field presenting the purpose is when the i/o field should appear on the screen.
 
I understand from your perspective that all coding should be on the plc, plc should control every thing even the HMI.
Is that what you mean?

I usually code on plc, but this is just for test purpose.

If I didn't get you well, and your welling to share elaborate more.
thx :)
 
Some SCADA software have powerful integrated programming languages, and one can use these to ezxpand the functionality of the SCADA. They are often intended for exactly that.
The VBS in WinCC does not belong to this category.

VBS should only be used to handle special tasks on the HMI that cannot be solved in any other way.
VBS should not be used in a cyclical manner, only triggered upon event. And these events should not be frequent.
VBS easily falls over.
VBS is a poor general purpose language.
VBS is singlethreaded.

I have said enough.
 

Similar Topics

Hello, I have a quick question. I have been using scripts to change the color of buttons. The reason, I am usually using multiple hmiruntime.tags...
Replies
1
Views
128
I am using Indusoft Version 8.1, and trying to use the VBScript button command to find a string in a column in a MySql database, and return all...
Replies
36
Views
8,779
Hi, Siemens TP900 Comfort: VBscript logging vs datalog I have a request from a customer. He needs to log around 10 real value's. The interval...
Replies
0
Views
2,242
Hi, I tried this: HMIRuntime.Screens("Mainscreen.bottomwindow:bottomwindow").ScreenItems("btn_body").back.color = RGB(255,255,255)...
Replies
1
Views
3,640
Hey guys. I am tyring connect from my HMI (TP1200) to a network location and open a file from a folder. The twist is I don't know what the file...
Replies
1
Views
4,751
Back
Top Bottom