Kkula
Browse Questions » SIMATIC WinCC: Label into a "String Tag"

About User

Questions Asked: 36.7K

Answers Given: 0

0
  • Open
  • New

SIMATIC WinCC: Label into a "String Tag"

Hi Guys,
I'm doing a string concatenation from two tags into a text. Now how can i make this text into a string tag? (Text variable 8-bit)
If it's possible in VB Script, please provide an example too. It'll be more helpful.
Thanks in Advance

0 Likes 0 Favourites 0 Followers 0 Comments
Answers(1)

Converting Text to String Tag in Siemens PLCs

You can convert concatenated text into a string tag (Text variable 8-bit) using VBScript within your Siemens PLC program (e.g., in a Function Block or Function). Here's how:

VBScript Example:


Dim strTag1, strTag2, strConcatenated, strResultTag
strTag1 = "Hello"
strTag2 = "World"
strConcatenated = strTag1 & " " & strTag2 'Concatenate strings
strResultTag = "YourStringTag" 'Name of your string tag
'Assuming "YourStringTag" is a global text tag defined in your PLC
'Assign the concatenated string to the string tag.
PLC_Tag(strResultTag) = strConcatenated

Explanation:

  • `strTag1` and `strTag2` hold the initial string values.
  • `strConcatenated` stores the result of the string concatenation.
  • `strResultTag` is the name of the 8-bit text tag you've already defined in your PLC project.
  • `PLC_Tag(strResultTag) = strConcatenated` assigns the value of `strConcatenated` to your PLC string tag.

Important: Make sure the `strResultTag` variable name matches exactly the name of your pre-defined text tag in the PLC's tag table. Also, ensure the string tag is large enough to accommodate the concatenated string.

For more details on VBScript in Siemens PLCs, refer to the SiePortal documentation: Siemens VBScript Examples.

0
Add a comment