title: Assigning userform textbox entry to a variable in VBA procedure
body: <p>I have code that produces a userform, titled MaterialForm, which contains a textbox, titled txtGravity. My goal is to take the entry in the txtGravity box, check it to determine if it is numerical, and then store the numerical value as a variable to use in my procedure.</p>
  
  <p>In the code that I am providing, the numerical check is working as intended and will only pass integers. The conversion from string to double is not working, however; and is storing the value "0" in my variable EnteredGrav.</p>
  
  <p>Here is the code</p>
  
  <pre><code>Private Sub Cmd_Save_Click()
      With txtGravity   'Check for non-numerical or empty values
      If IsNumeric(.Text) = False Or Len(.Text) = 0 Then
          .Text = ""
          MsgBox "It must be a numeric value"
          .SetFocus
          Exit Sub
      Else  'Convert the text (string) to the data type double
          EnteredGrav = CDbl(Trim(txtGravity.Value))
      End If
      End With
  End Sub
  </code></pre>
  
  <p>Thanks for any help you can provide!</p>