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

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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,214,405
Messages
6,119,315
Members
448,886
Latest member
GBCTeacher

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