For the complete documentation index, see llms.txt. This page is also available as Markdown.

Writing VB.NET Formulas

VB.NET is the language to use for new formulas. A VB.NET formula works the same on the desktop, in the 64-bit version and on the web.

Why convert older formulas?

Most formulas written in VBScript are not run on the web or in the 64-bit version of Logic ERP - only very simple one-line sums are still worked out, and everything else stays 0. Open such a formula and press Convert to VB.NET (see Convert to VB.NET).

The field names below (DA, HRA, ESIC, PF, INCENTIVE) stand for allowances and the rates are only examples. Use the names in your own Field List - in payroll they come from your company's allowance list. BASIC_SALARY, GROSS_SALARY and DEPARTMENT_NAME are standard payroll fields.

Store the result in a field

A formula works out a value and stores it in a field with =:

  • DA = GROSS_SALARY * 0.3065

  • A line that only works out a value, such as GROSS_SALARY * 0.3065, stores nothing. Check & Fix reports it as this line works out a value but does not store it (other messages may appear on the same line; adding the NAME = clears them).

Choose between values - If

If GROSS_SALARY > 21000 Then
    ESIC = 0
ElseIf GROSS_SALARY > 15000 Then
    ESIC = GROSS_SALARY * 0.0075
Else
    ESIC = GROSS_SALARY * 0.01
End If
  • Every If ends with End If. ElseIf is one word.

  • Compare with = (equal), <> (not equal), >, <, >=, <=. Join conditions with AndAlso and OrElse.

Choose from a list - Select Case

  • Text values are written in double quotes: "SALES".

  • Text must match exactly, including capital letters: "SALES" does not match "Sales".

Your own working values - Dim

A name that is not a field must be declared with Dim before it is used:

  • Do not use names that VB.NET already uses for its own words, such as Rate, Year, Month or Day - the message you get is then hard to understand.

Notes and layout

  • Text after ' is a note and is not run - on a line of its own or at the end of a line.

  • Indent the lines inside If, Select Case and loops. The indentation and the blank lines inside the formula are kept when it is saved and opened again (blank lines at the very top and bottom are removed), and they do not change the result.

Example - Ravi's HRA

HRA is 40% of the basic salary, but never more than 8,000. Ravi's basic salary is 25,000.

In the editor, click BASIC_SALARY in the Field List, type 25000 in the box next to its name and press Enter, then press Script Watch under Script Results. HRA shows 8000 (40% of 25,000 is 10,000, which is more than 8,000).