Why do I get an ovrflow on this line?

# Thread: Why do I get an ovrflow on this line?

1. Senior Member
Join Date
Dec 1969
Posts
135

## Why do I get an ovrflow on this line?

Why do I get an ovrflow on this line?<BR><BR>AprilPercent = Round((ActualApr / LastApr) * 100, 2)<BR><BR>Do you know why I would have an Overflow error on that line?<BR><BR>* Shalom<BR>* Israeli<BR>

2. Senior Member
Join Date
Dec 1969
Posts
11,334

## RE: Why do I get an ovrflow on this line?

Probably casting AprilPercent wrong.<BR><BR>Try <BR><BR>AprilPercent = CDbl(Round((ActualApr / LastApr) * 100, 2))<BR>

3. Senior Member
Join Date
Dec 1969
Posts
2,809

## RE: Why do I get an ovrflow on this line?

Because LastApr is 0 i bet...

4. Senior Member
Join Date
Dec 1969
Posts
2,809

## No, that ain't right...

You&#039;d get a division by zero error..sorry...

5. Senior Member
Join Date
Dec 1969
Posts
135

## This is correct. Thank You

I did an If statement to filter out <BR><BR>If LastApril &#060;&#062; 0 Then AprilPercent = Round((ActualApr / LastApr) * 100, 2) <BR><BR>That works greatly!<BR><BR>I had thought that this was not correct because I have gotten errors saying that I cannot divide by &#039;0&#039; in the past. (As you stated in your reply)<BR>So I thought that I should be getting that error if this LastApr were 0.<BR><BR>But I checked the database that the variable is being set from and the value was 0.<BR>Then If...Then statement cleared the error up nicely though.<BR><BR>* Shalom<BR>* Israeli<BR><BR>Thak You <BR>

6. Senior Member
Join Date
Dec 1969
Posts
2,809

## Huh...

For the overflow to occur, both ActualApr and LastApr have to be zero. Just something to think about. Good luck...

7. Senior Member
Join Date
Dec 1969
Posts
135

## I had thought this also.

I had thought this also.<BR><BR>I tried changing the datatype but still recieved the same error.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•