[en] Use VBScript effectively in NiceLabel

La traduction officielle n'est pas encore disponible.

[en] Problem

[en] NiceLabel software allows you to adapt to user requests for functionality not originally available in the software. Typical examples of such requests include:

  • [en] Complex check digit calculations.

  • [en] Decision making: conditional executing actions.

  • [en] Exchanging data with SQL server.

  • [en] Controlling external devices.

[en] NiceLabel Designer Pro/PowerForms, and Automation provide the Visual Basic Script (VB script) support to enhance NiceLabel with features not initially planned in the software.

[en] Solution

[en] NiceLabel supports the syntax of the VB script language but with some limitations.

[en] If NiceLabel displays an error in VBscript, verify the following:

[en] 1. Convert variables to numeric (CInt) when doing calculations. NiceLabel applications look at the variables as string values. Even if you define variables as numeric, NiceLabel prevents you from entering non-digit characters. The values are interpreted as strings.

[en] Convert your variables to Integer or Long Integer with the function CInt.

[en] 2. Assign the values to your variables at the beginning of the VB script

[en] If the variables are empty when you execute the VB script, the script validation fails.

[en] Define the variable values directly in the script.

[en] To check your variable values and execute statements, use a code like this:

If Myvariable <> "" Then
End If

[en] Write such code for all your variables.

[en] 3. Enclose the variables in square brackets if they include spaces in their names.

[en] For example, if you have the variable My Variable, use this syntax in the script [My Variable].

[en] If you can choose the variable names yourself, avoid using spaces in their names.

[en] 4. Enclose your variables/database field names in square brackets if they contain reserved names.

[en] When you write SQL sentences, enclose your variable/field names in square brackets, even if the names do not include spaces. This ensures that the SQL server sees the variable/field as such and not as the reserved names of SQL functionalities.

[en] For example, your field's name is FIELD. This is the reserved name, and you should avoid it. If you use it anyway, enclose it in square brackets: [FIELD].

[en] 5. Use the function-generated variable VBscript1 on the label

[en] NiceLabel has a built-in optimization technique to ignore the functions, which result is not used in your solution. The output VBscript functions are function-generated variables. To test that the VBscript function executes, place a text object with your function variable on the label or form.