title: VB.Net Converting from string to double
body: <p>I have a bad bug in my program where if a user presses the check(calculate) button when there is no input in the textbox the program displays this error: "Conversion from string "" to type 'Double' is not valid." I would like to resolve this but I am not sure how to do the conversion. I was thinking possibly CType but I am hearing talk of parsing. How do I go about this? the textbox is called mskTxtInput and the button object is called btnCheck which does all the calculation and processing.</p>
  
  <p>Update: This is my code except the parsing method so hope this helps a little!</p>
  
  <p>Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
          pic1.Visible = False     'hide picture
          pic1.Image = My.Resources.A
          pic2.Image = My.Resources.F</p>
  
  <pre><code>    Dim value As Double
      If Double.TryParse(mskTxtInput.Text, value) = Then
          MsgBox("parsing success") ' parsing worked, so use the value in here 
      Else
          MsgBox("parsing failed") ' parsing failed, so alert the user to that fact 
      End If
  
  
      If radAdd.Checked = True Then
          totalNum = num1 + num2
  
  
      End If
  
      If radSub.Checked = True Then
          totalNum = num1 - num2
  
      End If
  
      If radMulti.Checked = True Then
          totalNum = num1 * num2
  
  
  
      End If
  
      If mskTxtInput.Text = totalNum Then
          lblAns.Text = ("Correct!")
          lblAns2.Text = ("Answer is " &amp; totalNum)
          pic1.Visible = True
          wins = wins + 1
          nScore = wins
  
  
  
      Else
          lblAns.Text = ("Incorrect")
          lblAns2.Text = ("Answer should be " &amp; totalNum)
          pic2.Visible = True
  
      End If
  
      attempts = attempts + 1
      If attempts = 5 Then
          MessageBox.Show("Game Finished! ", "End Of Game", _
                          MessageBoxButtons.OK, _
                          MessageBoxIcon.Exclamation)
          lblAns.Text = ("You scored " &amp; wins &amp; " Out of 5")
          btnSpin.Enabled = False
          pic1.Visible = False
          pic2.Visible = False
          lblAns2.Text = ""
          lblAns2.Text = "Play again?"
          btnCheck.Enabled = False
          btnNew.Enabled = True
          attempts = 0
          wins = 0
      End If
  
  
      mskTxtInput.Clear()
      mskTxtInput.Focus()
  
  
  End Sub
  </code></pre>