IMDTouchKnowledge BaseShop main store

Explainer

What Visual Basic can and cannot do inside a WinCC project

HMI and touchscreens Published 7 min read

Short answer

There is no WinCC project setting that turns its C-like action script into Visual Basic. Visual Basic code enters a project only through documented boundaries: a VB-built DLL called with the #pragma code declaration, a registered ActiveX control, or WinCC ODK API calls from an outside program — plus VBA/VBS actions where the installed release documents them. Commissioning starts by reading the installed help, not by hunting for a hidden option.

On this page
  1. There is no setting that switches the script language
  2. The boundaries that bring Visual Basic in
  3. Check the installed release's help before you build
  4. Keep the native action a thin caller
  5. Calling WinCC from an outside program through the ODK
  6. Example: a one-function DLL bridge costs three lines
  7. The decision, case by case
  8. Questions asked

No WinCC project setting turns actions from the native C-like script into Visual Basic. Classic WinCC actions run in an interpreted C-like engine, fixed by the product and not chosen by configuration. A manual statement that WinCC can be programmed in C and Visual Basic describes integration boundaries, not a language selector: Visual Basic code enters through a VB-built DLL called with the #pragma code declaration, a registered ActiveX control on a page, or WinCC ODK API calls from an outside program — and as direct VBA/VBS actions only where the installed release documents them. This article maps each Visual Basic job to its boundary, shows what the installed help must document before you write code, and counts the smallest DLL bridge line by line.

There is no setting that switches the script language #

The actions behind graphic objects and the scheduled global actions are written in a C-like script that the runtime interprets at execution time. That interpreter is the action engine for the project, and nothing in project configuration replaces it with Visual Basic. The setup step the question assumes does not exist: you cannot configure VB as the action language. What you can do is call VB-built code across a documented edge, or write actions in VBA/VBS on a release whose help documents that language. Both are properties of the installation, verified against the installed help — never a hidden option to be found.

The boundaries that bring Visual Basic in #

Choose the boundary by the job the code must do, not by language preference:

The Visual Basic job The documented boundary What must agree across it
Run a calculation or nonvisual service from an action A DLL built in Visual Basic, called from the C action through the #pragma code declaration Exported function names, argument and return types, binary architecture, every dependency present on the runtime computer
Put a reusable visual element on a page A registered ActiveX control; IndustrialX was the package for building personalized controls with Visual Basic 5.0 Registration on the runtime computer, the control's properties, methods and events, page behavior after a runtime restart
Read or act on WinCC from an outside Visual Basic program WinCC ODK (Open Development Kit) API calls The ODK installed with the same release, the calls usable from Visual Basic, the exact API names
Write actions directly in Visual Basic syntax VBA or VBS, only where the installed release documents them The installed help names both the script editor and the runtime engine for that language

Every row leans on the installed help, because the exact declarations, registration steps and API names come from there — the table names the boundary, the help names the syntax.

The build side carries its own documentation trap: Visual Studio help search depends on registered content, so a missing search hit can mean an unregistered help package rather than an unsupported call.

Check the installed release's help before you build #

An answer to this same question recorded in 2002 said the next WinCC release would support VBA/VBS as well as C — and named no release. Product history cannot be walked backwards from that sentence to your installation, and neither can the product name or the age of the license: the decider is the help installed on your machine.

Record the release the engineering environment reports, then search the installed help for four things: the script languages it documents, the #pragma recipe for external DLLs, ActiveX integration, and the ODK. Each hit opens a boundary for your installation; each miss closes one.

Limits also move between product lines, not only between releases: WinCC Unified scripts cannot launch a batch file at all, and a technique proven on one WinCC generation proves nothing about the next.

If the help documents a boundary, build against it. If it does not, that boundary is closed for that installation, and no amount of option-hunting opens it.

Keep the native action a thin caller #

The C-like script is interpreted, so heavy script work shows up as sluggish pages rather than as an error message. The working split: the action gathers its inputs, calls the DLL function or control method, checks the result, and writes the output, while the substantial reusable processing lives in the compiled component. Keep event handlers short — a high-frequency control event that re-enters interpreted script on every firing rebuilds the slowdown the component was meant to remove.

None of this is a home for safety logic: HMI script and Visual Basic components sit outside the safety-related control path, and a safety function belongs in the safety controller, wired and validated to its own standard.

Calling WinCC from an outside program through the ODK #

The Open Development Kit exposes API calls for both the development environment and the runtime environment. It is the boundary for a Visual Basic program that acts on WinCC from outside — reading data, working with alarms, preparing projects — rather than for a page action that needs a calculation. Keep the two environments separate in design: a call that edits engineering data is not interchangeable with one that acts on a running system.

The ODK help shipped with your release is the contract for all of this, down to specifics such as language-neutral access to alarm messages in the ODK help.

If the target is alarm text rather than general API access, check first whether you can read WinCC alarm text without the ODK, because that route avoids the kit entirely.

Example: a one-function DLL bridge costs three lines #

The case: the smallest bridge that proves the DLL boundary — one user-defined C action calling one exported function in a DLL built with Visual Basic, passing one input value and returning one result.

Inputs and where each comes from:

  • 1 exported function, 1 input value, 1 return value — the smallest interface that can prove the bridge, chosen by the build rule in the previous sections.
  • 2 #pragma code lines per DLL interface, from the documented recipe for calling DLL functions from a user-defined C function (release V20 TIA documentation): the block opens with #pragma code("<Name>.dll"), naming the DLL in quotes, and closes with a second #pragma code line.
  • 1 prototype line declaring the exported function inside that block, from the same recipe.

The rule in words: lines added to the C action = 2 pragma lines + 1 prototype per function the action calls.

The arithmetic: one function gives 2 + 1 = 3 lines. Add a second exported function to the same DLL and the count is 2 + 2 = 4, because the pragma pair is charged once per DLL, not once per function.

The result: the one-function bridge adds 3 lines to the C action and leaves the calculation in a compiled binary the runtime loads as a separate component.

The decision: where the installed help documents this recipe, budget 3 lines for the first function and prove the bridge before production data touches it — 1 deliberate trigger producing exactly 1 observable effect, with no script diagnostic and no progressive page slowdown. Where the help does not document the recipe, the DLL boundary is closed for that installation, and the choice falls to the ActiveX or ODK row of the table.

The decision, case by case #

  • A calculation or service an action must start: the Visual Basic DLL behind the #pragma code recipe, if the installed help documents it — prove the smallest call first.
  • A reusable visual element on a page: a registered ActiveX control, the IndustrialX route built for controls developed in Visual Basic 5.0 — proven on a disposable page, then again after a runtime restart.
  • An outside program that must read or drive WinCC: the ODK, with development and runtime calls kept separate by design.
  • Actions written directly in Visual Basic syntax: only on a release whose installed help documents VBA/VBS. Everywhere else the opening answer stands — no setting exists, the actions stay C-like, and Visual Basic arrives only across the boundaries above.

Commission in that order: record the release, read the installed help, pick the boundary by the job, prove the smallest case — then connect production tags.

Questions asked

Does a Visual Basic DLL that passes its own test project prove the WinCC side works?

No. A clean result inside the Visual Basic environment proves the calculation, not the bridge. The WinCC-side proof loads that exact binary on the runtime computer, calls it through the documented declaration, and gets the expected value back with no script diagnostic. Architecture mismatches and missing dependencies only appear in that runtime test, which is why it runs before any production tag or operator command is connected.

Can a .NET assembly be called like a classic Visual Basic DLL?

Not through the C-action recipe. A .NET assembly is not a plain Win32 DLL, so a #pragma code declaration aimed at it will not find exported functions to call. The documented route for script environments is the COM pattern: make the assembly visible to COM, register it on the runtime computer, then reach it through CreateObject. Check the installed WinCC help for which of its two documented DLL patterns applies to your release.

How do I confirm whether my release supports VBA or VBS actions?

Open the help installed with that exact release and search it for VBA, VBS and the scripting chapters of its information system. A supported language shows two things: a documented editor for writing the actions and a documented runtime engine that executes them. If the help names neither, the release has no VBA/VBS path, whatever its age or product name suggests.

Where is the reference for IndustrialX, the Visual Basic controls package?

The Siemens support reference associated with IndustrialX, the package for building personalized ActiveX controls with Visual Basic 5.0, is Entry ID 4293966. Whatever tool built the control, WinCC takes the finished artifact as an ActiveX component: registration on the runtime computer, then its properties, methods and events reached from page script. The boundary to prove is registration and page behavior, not the language it was written in.

Does the ODK give a Visual Basic program the same reach as C++?

Treat it as a subset until your installation proves otherwise. The ODK documents API calls for both the development and the runtime environment, but Visual Basic access can be narrower and less direct than the C++ access. The usable surface for your project is what the ODK examples and declarations shipped with the same WinCC installation expose, so plan the outside program around those examples and check every call's return status.

Keep reading

  • How-to

    Deploy a WinCC 6.2 Project on a Separate Runtime PC

    Install WinCC 6.2 on both machines: Runtime installs with the same setup, so there are no separate runtime files to carry. License the desktop PC that activates the project, copy the whole project folder to it, register the folder in AutoStart, and build the job as a Single-User Project.

    HMI and touchscreens

  • Troubleshooting

    Why WinCC Runtime Reports Project Is Locked and How to Recover

    "Project is locked" in WinCC Runtime is an ownership conflict, not a license fault: a live session, or a stale ProjectOpened.lck left behind by a crash or power loss, still claims the project. Close every session that could own it, back it up, then clear the lock with reset_wincc.vbs or by removing ProjectOpened.lck; on a client, open the project by its UNC path.

    HMI and touchscreens

  • How-to

    Running a WinCC 7.0 project on another PC without a new build

    No. WinCC has no compile-to-EXE option: the destination PC needs WinCC Runtime of version 7.0 or higher, installed and licensed, and you transfer the project files to it. A newer WinCC opens and converts the project; an older release will not open it.

    HMI and touchscreens