> 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/convert-to-vb.net.md).

# Convert to VB.NET

**Convert to VB.NET** rewrites a formula written in **VBScript** or **PowerShell** as a **VB.NET** formula, so that it also works on the web and in the 64-bit version. The button is available in the **Script Editor** when the **Language** is **VBScript** or **PowerShell**.

Nothing is saved by the conversion. You test the converted formula and save it as usual; **Close** without saving keeps the original.

### **Convert a formula**

* Open the formula in the **Script Editor** and press **Convert to VB.NET**.
* The **Convert to VB.NET** window shows the original formula (**Original (VBScript)** or **Original (PowerShell)**) and the converted one (**Converted (VB.NET) - this goes into the editor**) side by side.
* **What to check** lists the points of the conversion with their lines: **Fix** (must be corrected before VB.NET will save the formula) first, then **Check** (worth a look) and **Note** (information only).
* The window's title shows how many are left, for example *Convert to VB.NET - 0 to fix, 1 to check*.

### **Names that are not fields**

If the formula uses a name that is not a field of this screen - often a spelling mistake or a field that was renamed - it is listed under **Names that are not fields of this screen - choose, then Convert again**.

* Select the name and pick what to use in **Use instead:**
  * for a name the formula only reads: the right field, or **0**;
  * for a name the formula stores a value in: the right field, or **(keep as a working variable)**.
* Press **Convert again** to see the result.

### **Other options**

* **Remove lines commented out with '' (old code)** leaves out old lines that were already switched off in the original.

### **Use the converted formula**

* Press **Use converted script**. If points marked **Fix** are left you are asked: *The converted script still has points marked Fix. VB.NET will not save it until they are corrected in the editor. Put it in the editor anyway?* (the default answer is **No**).
* The editor shows the formula with the **Language** set to **VB.NET** and the message *The script is now VB.NET. Press Watch to test it, then Save. Nothing has been saved yet - closing without saving keeps the original script.*
* Test it with **Script Watch** and press **Save**.
* **Cancel** closes the window and leaves the editor as it was.

### **What the conversion does for you**

* A line at the top records the date of the conversion, and the original formula is kept at the bottom as notes, so you can always see what it was.
* A **division by zero gives 0** for that value. Before, the whole formula stopped and its values showed 0.
* A PowerShell **ForEach** that goes through a variable column group (see **Script Editor**) becomes a VB.NET **For Each**. Each column's **Value** is read as a number with **Val**, and a **Note** says so; a blank value counts as **0**.
* In a VBScript formula, the **Value** of a column in a variable column group is also read as a number.
* If a VBScript formula uses a whole variable column group where one value is expected, the line is listed under **Fix** and marked **NOT\_CONVERTED\_** followed by the group's name, until you rewrite it - go through the group with **For Each**, or pick one column.

### **Check after converting a variable column group**

* PowerShell compared a column's value as text, so a check such as **-gt 0** also let a **negative** value through. The converted formula compares numbers and leaves negative values out. If a group can hold negative values, compare a few results before saving, and change **> 0** to **<> 0** if they should be counted.


---

# 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/convert-to-vb.net.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.
