> For the complete documentation index, see [llms.txt](https://kb.logicerp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/writing-formulas-in-the-script-editor/check-and-fix.md).

# Check & Fix

**Check & Fix** finds the mistakes in a **VB.NET** formula, corrects the usual ones for you and lists, by line, what you still need to correct. It is meant for anyone who writes formulas only now and then.

The button is in the **Script Editor** when the **Language** is **VB.NET**. You are also offered it when **Script Watch** or **Save** finds that the formula has a mistake: the message *The VB.NET script does not compile:* shows the first mistake and asks *Open Check & Fix to see every problem by its line and fix the usual mistakes?*

Nothing is saved by **Check & Fix**. The corrected formula goes back to the editor only when you press **Apply to editor**; then test it and save as usual.

### **What it corrects for you**

* A block left open: a missing **End If**, **Next**, **Loop**, **End While**, **End Select**, **End With**, **End Try**, **End Sub** or **End Function**.
* Words written the old way: **EndIf**, **EndSelect**, **Wend**, **Else If** and the like, in any letter case.
* A missing **Then** at the end of an **If** or **ElseIf** line.
* Signs from other languages: **==**, **!=**, **&&**, **||**, a **;** at the end of a line, **//** for a note, a line with only **{** or **}**.
* A field name with a small spelling mistake - for names of 5 letters or more, at most 1 letter wrong (2 for names of 8 letters or more), and only when there is just one field it can be.
* A working value the formula stores a value in (NAME = ...) but never declared - a **Dim** line is added for it.
* The indentation (4 spaces per level) and the letter case of words such as **If**, **Then** and **End If**.

### **The window**

* The top line sums up the result, for example *2 change(s) made - the script now compiles. Press Apply to editor, then Watch to test it.* When something is left, it says how many problems you must fix by hand.
* **What was found** lists every point with its **Line**, **What** and **Status**: **Fix by hand** (you must correct it) first, then **Fixed** (what was changed for you).
* Double-click a **Fix by hand** row to go to its line in the formula.
* **The script after the fixes** - you can still change it here, then press **Check again** to check the formula as it is now shown.
* **Apply to editor** puts the formula in the editor; if problems are left, their first line is selected there. **Cancel** leaves the editor as it was.
* On the web, on a phone or narrow screen, use **Problems** and **Script** at the top to switch between the list and the formula.

> **Example - a formula with the usual mistakes**
>
> Sunita writes this formula, where **PF** is a field of the screen:
>
> ```
> If GROSS_SALARY > 15000
>     PF = BASIC_SALARY * 0.12;
> else if GROSS_SALARY == 0
>     PF = 0
> endif
> ```
>
> **Check & Fix** shows:
>
> ```
> If GROSS_SALARY > 15000 Then
>     PF = BASIC_SALARY * 0.12
> ElseIf GROSS_SALARY = 0 Then
>     PF = 0
> End If
> ```
>
> and lists as **Fixed**: **Then** added (lines 1 and 3), the **;** removed, **==** changed to **=**, **Else If** written **ElseIf**, and **endif** written **End If**. The top line says *6 change(s) made - the script now compiles.* She presses **Apply to editor**, then **Script Watch**, then **Save**.

### **Problems you correct yourself**

Some mistakes need your decision. They are listed as **Fix by hand** in plain words, for example:

* *this text value has no closing " - end it on this line*
* *'GROSS\_SAL' is not a field and was not declared with Dim (check the spelling)*
* *this line works out a value but does not store it - write NAME = ...*
* *End If has no If before it - check the blocks above*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://kb.logicerp.com/logic-erp-learning-hub-tutorials-and-best-practices/writing-formulas-in-the-script-editor/check-and-fix.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
