Rune-time 6 overflow

kylec23

New Member
Joined
Jan 12, 2022
Messages
17
Office Version
  1. 365
Platform
  1. Windows
I am trying to run the follow code. Not sure why I'm getting an overflow because the equations that are being performed are super simple and not returning large values.

VBA Code:
TextBox5.Value = Val(TextBox1.Value) / Val(TextBox2.Value)

Any help is appreciated
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
if is almost undoubtedly because Val(textbox2.value is zero at some point which will give you an overflow, probably when the textbox first opens :so change the code to this:
VBA Code:
If Val(TextBox2.Value) <> 0 Then
TextBox5.Value = Val(TextBox1.Value) / Val(TextBox2.Value)
Else
TextBox5.Value =0
End If
 
Upvote 0
Solution
if is almost undoubtedly because Val(textbox2.value is zero at some point which will give you an overflow, probably when the textbox first opens :so change the code to this:
VBA Code:
If Val(TextBox2.Value) <> 0 Then
TextBox5.Value = Val(TextBox1.Value) / Val(TextBox2.Value)
Else
TextBox5.Value =0
End If

This worked, so thank you very much for that.
Would you be able to explain to me how Val(TextBox2.Value) would be returned zero when in fact that was a number that was input?
 
Upvote 0
I woudl assume it would be zero before you make the input, thus that is probably when it crashes
 
Upvote 0
If textbox2 was 0 you would get a division by 0 error, not an overflow error.
What were the 2 numbers when you got the error?
 
Upvote 0
If textbox2 was 0 you would get a division by 0 error, not an overflow error.
What were the 2 numbers when you got the error?
I was trying super simple things to test. 70/10, 60/6. Nothing crazy.
 
Upvote 0
I cannot replicate the error you are getting with those numbers, or any others. So not sure why that is happening.
 
Upvote 0
Do you have any code behind textbox5?
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top