title: VBA - UserForm with multiples TextBoxes in infinite calculation loop
body: <p>I have an UserForm with 5 TextBoxes, and each time one is updated I recalculate the others.</p>
  
  <p>But <strong>how do I avoid a "infinite loop"</strong> as the first will recalculate second which will recalculate the first and so on...</p>
  
  <p>Here is a part of my UserForm's code, only the TextBox_Change(s) :</p>
  
  <pre><code>Private Sub TxtNewVal_Change()
  If InStr(1, Me.TxtNewVal.Value, ",") Then Me.TxtNewVal.Value = Val(Replace(Me.TxtNewVal.Value, ",", "."))
  
  'recalculate values
  If Right(Me.TxtNewVal.Value, 1) &lt;&gt; "." Then
      Me.TxtValEUR.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxEUR.Value)
      Me.TxtValUSD.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxUSD.Value)
  End If
  End Sub
  
  
  Private Sub TxtTxEUR_Change()
  If InStr(1, Me.TxtTxEUR.Value, ",") Then Me.TxtTxEUR.Value = Val(Replace(Me.TxtTxEUR.Value, ",", "."))
  If Val(Me.TxtTxEUR.Value) = 0 Then Me.TxtTxEUR.Value = TxEur
  'recalculate values =
  If Right(Me.TxtTxEUR.Value, 1) &lt;&gt; "." Then Me.TxtValEUR.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxEUR.Value)
  'Me.TxtValUSD.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxUSD.Value)
  End Sub
  
  
  Private Sub TxtTxUSD_Change()
  If InStr(1, Me.TxtTxUSD.Value, ",") Then Me.TxtTxUSD.Value = Val(Replace(Me.TxtTxUSD.Value, ",", "."))
  If Val(Me.TxtTxUSD.Value) = 0 Then Me.TxtTxUSD.Value = TxUsd
  'recalculate values =
  'Me.TxtValEUR.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxEUR.Value)
  If Right(Me.TxtTxUSD.Value, 1) &lt;&gt; "." Then Me.TxtValUSD.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxUSD.Value)
  End Sub
  
  
  Private Sub TxtValEUR_Change()
      If InStr(1, Me.TxtValEUR.Value, ",") Then Me.TxtValEUR.Value = Val(Replace(Me.TxtValEUR.Value, ",", "."))
  'recalculate values =
  'Me.TxtValEUR.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxEUR.Value)
  
  If Val(Me.TxtTxEUR.Value) &lt;&gt; 0 And Right(Me.TxtValEUR.Value, 1) &lt;&gt; "." Then _
      Me.TxtNewVal.Value = Val(Me.TxtValEUR.Value) / Val(Me.TxtTxEUR.Value)
  'Me.TxtValUSD.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxUSD.Value)
  End Sub
  
  
  
  Private Sub TxtValUSD_Change()
      If InStr(1, Me.TxtValUSD.Value, ",") Then Me.TxtValUSD.Value = Val(Replace(Me.TxtValUSD.Value, ",", "."))
  'recalculate values =
  If Val(Me.TxtTxUSD.Value) &lt;&gt; 0 And Right(Me.TxtValUSD.Value, 1) &lt;&gt; "." Then _
      Me.TxtNewVal.Value = Val(Me.TxtValUSD.Value) / Val(Me.TxtTxUSD.Value)
  'Me.TxtValEUR.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxEUR.Value)
  'Me.TxtValUSD.Value = Val(Me.TxtNewVal.Value) * Val(Me.TxtTxUSD.Value)
  End Sub
  </code></pre>