title: VBA Excel TimeValue() input possibilities
body: <p>new here. Read a lot of topics but really can't figure this out.
  I'm converting a string from a userform textbox to a double, representing a time. Current code works pretty good:</p>
  
  <pre><code>Dim startingTime As Double, endingTime As Double
  Dim totalTime As Double
  On Error Resume Next
  With textbox_inMyUserform
  TimeValue(.Value)
      If Err.Number &lt;&gt; 0 Then
          startingTime = CDbl(.Value)
          Err.Clear
          On Error GoTo 0
      Else
          On Error GoTo 0
          startingTime = 24 * TimeValue(.Value)
      End If
  End With
  </code></pre>
  
  <p>the TimeValue(.value) checks if the format is correct. No error means that function is used in else, an error makes the if run a normal Cdbl(.value).</p>
  
  <p>Works great, except... decimals apparantly don't trigger an error. "5" becomes 5 because of an error on TimeValue, "5:30" becomes 5,5 because no error on TimeValue but "5.5" and "5,5" don't trigger errors giving respective results of 5.0833333 and 0 through the TimeValue(.value). I expect errors on those strings?</p>
  
  <p>My solution now would be to just not use decimals, but I wan't to know what's wrong.</p>
  
  <p>Thanks.</p>
  
  <p><strong>update</strong><br>
  So based on the answer of Slai I got it to work. Apparently TimeValue() in VBA and TIMEVALUE() inside of excel behave differently. Also I put my originally planned 'if not IsError()' back in.</p>
  
  <pre><code>Dim startingTime As Double, endingTime As Double
  Dim totalTime As Double
  With textbox_starttijd
      If Not IsError(Evaluate("TIMEVALUE(""" &amp; .Value &amp; """)")) Then
          startingTime = 24 * TimeValue(.Value)
      ElseIf .Value &lt;&gt; vbNullString Then
          startingTime = CDbl(.Value)
      Else
          startingTime = 0
      End If
  End With
  With textbox_eindtijd
      If Not IsError(Evaluate("TIMEVALUE(""" &amp; .Value &amp; """)")) Then
          endingTime = 24 * TimeValue(.Value)
      ElseIf .Value &lt;&gt; vbNullString Then
          endingTime = CDbl(.Value)
      Else
          endingTime = 0
      End If
  End With
  totalTime = endingTime - startingTime
  </code></pre>
  
  <p><strong>Update 2</strong><br>
  might as well keep this code up to date: an empty textbox in the userform throws an error at 'CDbl(.value)' so I updated the code above with an ElseIf that checks against vbNullString and the Else sets my time to 0 so the string now is never empty.</p>