# vba error 6 overflow

1. ## vba error 6 overflow

Hey,

In my userform I calculate formulas that come into my Access database.
These are doubles, so when I fill in 0 I get error 13 saying I can't
fill that i because that will cause an overflow. When I try with with
errormessages to get passed error 13 I get the overflow problem. My
problem is that sometimes it should be possible to fill in 0 but that
my formula then sets it's value tot 0 or something.

Is there someone who could help me out with this?

This is an example of a line with a formula:

rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)

So when I fill in 0 in the textbox on the userform for TekstVoor I got
stuck.

2. ## Re: vba error 6 overflow

I think I'd just check to make sure that the value in TekstVoor is non-zero.
I'm not sure what should happen, but dividing by 0 is usually a bad idea.

dim res as variant

res = "Error!

if isnumeric(tekstvla.value) _
and isnumeric(tekstvvkt.value) _
and isnumeric(tekstvoor.value) then
if cdbl(ekstvoor.value) <> 0 then
res = (CDbl(TekstVla.value) - CDbl(TekstVVKT.value)) _
/ CDbl(TekstVoor.value)
end if
end if

worksheets("rs").range("Acid_test").value = res

tinybears wrote:
>
> Hey,
>
> In my userform I calculate formulas that come into my Access database.
> These are doubles, so when I fill in 0 I get error 13 saying I can't
> fill that i because that will cause an overflow. When I try with with
> errormessages to get passed error 13 I get the overflow problem. My
> problem is that sometimes it should be possible to fill in 0 but that
> my formula then sets it's value tot 0 or something.
>
> Is there someone who could help me out with this?
>
> This is an example of a line with a formula:
>
> rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)
>
> So when I fill in 0 in the textbox on the userform for TekstVoor I got
> stuck.
>

--

Dave Peterson

3. ## Re: vba error 6 overflow

tinybears wrote:
> Hey,
>
> In my userform I calculate formulas that come into my Access database.
> These are doubles, so when I fill in 0 I get error 13 saying I can't
> fill that i because that will cause an overflow. When I try with with
> errormessages to get passed error 13 I get the overflow problem. My
> problem is that sometimes it should be possible to fill in 0 but that
> my formula then sets it's value tot 0 or something.
>
> Is there someone who could help me out with this?
>
> This is an example of a line with a formula:
>
> rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)
>
> So when I fill in 0 in the textbox on the userform for TekstVoor I got
> stuck.

The problem is, there is no valid value for this to produce when
TekstVoor is 0. You can't divide by 0. It's not defined. It's not
even defined when the numerator is 0. Excel is doing the
correct thing by giving you an error message.

If you want to be able to handle user input of 0 for this variable,
you need to put in a test for 0, and use a formula that does
not divide by 0 to handle that case. Probably what you want
is to check if abs(TekstVoor) is less than some value, say
1E-10 or something, and if it is, then use a formula that does
not have 1/TekstVoor in it.
Socks

4. ## Re: vba error 6 overflow

hey thx,

I solved it something like this:

If TekstVoor = 0 Then
rs!Acid_test = 0
TekstVoor = 0
Else
rs!Acid_test = (CDbl(TekstVla) - CDbl(TekstVVKT)) / CDbl(TekstVoor)
End If

greetz

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1