Thread: VBA Error
View Single Post
  #3   Report Post  
Duke Carey
 
Posts: n/a
Default

Since the error is divide by zero, and the only place in that line where
there's division taking place uses txtHrs2.Text as the divisor, then it
appears that txtHrs2.Text is blank or otherwise equal to 0

When you get the error you can hover the mouse over txtHrs2.Text to see its
value to confirm that is the issue. If so you'll have to figure out why it's
zero when you don't think that's the case.


"mully" wrote:

Hi

On a UserForm everything works OK all the boxes fill with the correct
information -- however on hitting enter the following error message appears.

Division By Zero

in the VBA the bottom line of the following code is highlighted

Private Sub txtHrsTime_Change()
Me.txtHrs2.Value = (Val(Trim(txtHrsTime.Text))) * 60
Me.txtVel2.Value = (Val(Trim(txtDis2.Text))) / (Val(Trim(txtHrs2.Text)))
End Sub

On viewing the sheet everything has been entered in the correct Cells --
this bug is really bugging me.

Also how do you restrict the numbers after the decimal point in a Text Box.

Any help much appreciated

Cheers ---- Mully