Senhores, bom dia!
Reformulei o projeto, que ficou horrível mas agora está funcionando.
Option Explicit
Private Sub CommandButton1_Click()
'Dim T As Control
'TextBox1.SetFocus
'For Each T In UserForm1.Controls
' If TypeName(T) = "TextBox" Then
' T.Value = ""
' End If
'Next T
Me.TextBox6.Value = ""
Me.TextBox8.Value = ""
Me.TextBox9.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox7.Value = ""
Me.TextBox1.SetFocus
End Sub
Private Sub TextBox1_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double
If IsNumeric(Me.TextBox1.Text) Then num1 = CDbl(Me.TextBox1.Text) Else num1 = 0
End Sub
Private Sub TextBox2_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double
If IsNumeric(Me.TextBox2.Text) Then num2 = CDbl(Me.TextBox2.Text) Else num2 = 0
End Sub
Private Sub TextBox3_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double
If IsNumeric(Me.TextBox3.Text) Then num3 = CDbl(Me.TextBox3.Text) Else num3 = 0
End Sub
Private Sub TextBox4_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double
If IsNumeric(Me.TextBox4.Text) Then num4 = CDbl(Me.TextBox4.Text) Else num4 = 0
End Sub
Private Sub TextBox5_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double, num7 As Double, num8 As Double, num9 As Double
On Error Resume Next
If Me.TextBox6 < 0 Then Exit Sub
If IsNumeric(Me.TextBox1.Text) Then num1 = CDbl(Me.TextBox1.Text) Else num1 = 0
If IsNumeric(Me.TextBox2.Text) Then num2 = CDbl(Me.TextBox2.Text) Else num2 = 0
If IsNumeric(Me.TextBox3.Text) Then num3 = CDbl(Me.TextBox3.Text) Else num3 = 0
If IsNumeric(Me.TextBox4.Text) Then num4 = CDbl(Me.TextBox4.Text) Else num4 = 0
If IsNumeric(Me.TextBox5.Text) Then num5 = CDbl(Me.TextBox5.Text) Else num5 = 0
If IsNumeric(Me.TextBox6.Text) Then num6 = CDbl(Me.TextBox6.Text) Else num6 = 0
Me.TextBox6 = Format(((num1 + num2) * num3 * (num4 / 10) * num5) / (num1 * num2), "##,###0.000")
End Sub
Private Sub TextBox6_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double, num7 As Double, num8 As Double
If IsNumeric(Me.TextBox6.Text) Then num6 = CDbl(Me.TextBox6.Text) Else num6 = 0
Me.TextBox8 = Format(num6 * num7, "##,###0.000")
End Sub
Private Sub TextBox7_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double, num7 As Double, num8 As Double, num9 As Double
If IsNumeric(Me.TextBox6.Text) Then num6 = CDbl(Me.TextBox6.Text) Else num6 = 0
If IsNumeric(Me.TextBox7.Text) Then num7 = CDbl(Me.TextBox7.Text) Else num7 = 0
Me.TextBox8 = Format(num6 * num7, "##,###0.000")
End Sub
Private Sub TextBox8_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double, num7 As Double, num8 As Double, num9 As Double
If IsNumeric(Me.TextBox8.Text) Then num8 = CDbl(Me.TextBox8.Text) Else num8 = 0
Me.TextBox9 = Format(num8 / 20, "##,#0.00")
End Sub
Private Sub TextBox9_Change()
Dim num1 As Double, num2 As Double, num3 As Double, num4 As Double, num5 As Double, num6 As Double, num7 As Double, num8 As Double, num9 As Double
If IsNumeric(Me.TextBox6.Text) Then num6 = CDbl(Me.TextBox6.Text) Else num6 = 0
If IsNumeric(Me.TextBox7.Text) Then num7 = CDbl(Me.TextBox7.Text) Else num7 = 0
If IsNumeric(Me.TextBox8.Text) Then num8 = CDbl(Me.TextBox8.Text) Else num8 = 0
If IsNumeric(Me.TextBox9.Text) Then num9 = CDbl(Me.TextBox9.Text) Else num9 = 0
Me.TextBox9 = Format(num8 / 20, "##,#0.00")
End Sub
Obrigado a todos!
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 24/11/2015 8:26 am