error in userform
I think I'd check to make sure everything was numeric and that textbox3.value
was different than 1 (no div/0 errors):
Option Explicit
Private Sub TextBox2_Change()
If IsNumeric(Me.TextBox1.Value) _
And IsNumeric(Me.TextBox2.Value) _
And IsNumeric(Me.TextBox3.Value) Then
If Me.TextBox3.Value < 1 Then
Me.Label7.Caption _
= Format(CDbl(TextBox1.Value - TextBox2.Value) _
/ (TextBox3.Value - 1), "# ??/16")
Else
Me.Label7.Caption = ""
End If
End If
End Sub
And Format worked ok for me instead of application.text--not all number formats
can be done this way, but this one was ok.
damorrison wrote:
I have text boxes and labels that show values, using formulas such as
the code below for Label7:
Private Sub TextBox2_Change()
Label7.Caption = Application.Text(CDbl(TextBox1.Value - TextBox2.Value)
/ (TextBox3.Value - 1), "# ??/16")
End Sub
If I am in textbox2 and enter a value, it works fine, if I want to
change the value by pressing back space I get a error, because (I
assume, it becomes a zero error)
..is there a way to trap this error and still be able to stay in the
textbox?
--
Dave Peterson
|