> For the complete documentation index, see [llms.txt](https://docs.gapvelocity.ai/vbuc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gapvelocity.ai/vbuc/issues-troubleshooting/vb6-and-.net-integer-division.md).

# VB6 and .NET integer division

#### Description

In VB6 AI Migrator versions lower than 8.2, the division between two integers is migrated to a non-equivalent statement.

Consider the following VB6 code:

**VB6 Code**

```php
Dim nLineCnt As Long
Dim nSplit As Long
Dim nItems As Long

'more code'

nItems = CLng(nLineCnt / nSplit)
```

The code was migrated to this:

**.NET Code**

```csharp
int nLineCnt = 0;
int nSplit = 0;
int nItems = 0;

//more code 

nItems = nLineCnt / nSplit;
```

That division statement is not equivalent in .NET because, for operands of integer type, the / operator returns an integer, consisting of the quotient rounded towards zero.

Consider the following examples:

**VB6 Code**

```php
Dim nLineCnt As Long
Dim nSplit As Long
Dim nItems As Long

'more code'

nLineCnt = 13
nSplit = 5

nItems = CLng(nLineCnt / nSplit) 'nItems is 3'
```

The result in VB6 is 3.

**.NET Code**

```csharp
int nLineCnt = 13;
int nSplit = 5;
int nItems = 0;

//more code 

nItems = nLineCnt / nSplit; //nItems is 2
```

The result in .NET is 2.

To obtain a floating-point quotient, one of the operands should be cast as float, double, or decimal type:

**.NET Code**

```csharp
int nLineCnt = 13;
int nSplit = 5;
int nItems = 0;

//more code 

nItems = Convert.ToInt32((double)nLineCnt / nSplit); //nItems is 3
```

The result with the modifications is 3.

The code is now equivalent. Notice the result should be converted to an integer.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gapvelocity.ai/vbuc/issues-troubleshooting/vb6-and-.net-integer-division.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
