title: "Conversion from string to type Double is not valid" error VB.NET
body: <p>I'm trying to display a logged in users balance from a database in VB. However once I click the Check Balance button it produces the error <code>Conversion from string "Your balance is " to type 'Double' is not valid</code>. </p>
  
  <p>I've tried different ways a converting it from a string to a double, I thought maybe it was because I had m_decBalance declared as a decimal, but that didn't change anything. Can anyone help me? Here's my code: </p>
  
  <pre><code>Imports MySql.Data
  Imports MySql.Data.MySqlClient
  
  Public Class Form1
  
      Dim dbCon As MySqlConnection
      Dim strQuery As String = ""
      Dim SQLcmd As MySqlCommand
      Dim DataReader As MySqlDataReader
  
      Private m_strPass As String
      Private m_decBalance As Decimal
      Private m_strName As String
      Private m_strUserPass As String
      Private m_strCardNumber As String
  
      Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
  
          'Assign users guessed password to variable
          m_strUserPass = txtPass.Text
  
          'Invoke
          RetrieveAccountInformation()
  
          ' determine if Password is correct or not
          If m_strUserPass = m_strPass Then
              lblWelcome.Visible = True
              lblWelcome.Text = "Welcome" + " " + m_strName
  
              txtPass.Enabled = False
              btnBalance.Enabled = True
          Else
              ' indicate that incorrect password was provided
              lblWelcome.Visible = True
              lblWelcome.Text = "Sorry, Password is incorrect." _
             &amp; "Please retry ."
  
              ' clear user's previous PIN entry
              m_strUserPass = ""
          End If
          txtPass.Clear() ' clear TextBox
      End Sub
  
      ' load application Form
      Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  
          'Prepare connection and query
          Try
              dbCon = New MySqlConnection("Server=localhost;Database=test;Uid=root;Pwd=mysql")
              strQuery = "SELECT CardNumber " &amp;
                     "FROM Account"
              SQLcmd = New MySqlCommand(strQuery, dbCon)
  
              'Open the connection
              dbCon.Open()
  
              ' create database reader to read information from database
              DataReader = SQLcmd.ExecuteReader
  
              ' fill ComboBox with account numbers
              While DataReader.Read()
                  cboAccountNumbers.Items.Add(DataReader("CardNumber"))
              End While
  
              'Close the connection
              DataReader.Close()
              dbCon.Close()
          Catch ex As Exception
              'Output error message to user with explaination of error
              MsgBox("Failure to communicate" &amp; vbCrLf &amp; vbCrLf &amp; ex.Message)
          End Try
      End Sub
  
      ' invoke when user provides account number
      Private Sub RetrieveAccountInformation()
          ' specify account number of record from which data will be retrieved
          dbCon = New MySqlConnection("Server=localhost;Database=test;Uid=root;Pwd=mysql")
          strQuery = "SELECT Name, Balance, Password " &amp;
              "FROM Account WHERE CardNumber='" &amp; Val(cboAccountNumbers.Text) &amp; "' "
          SQLcmd = New MySqlCommand(strQuery, dbCon)
          dbCon.Open() ' open database connection
  
          ' create database reader to read information from database
          DataReader = SQLcmd.ExecuteReader
          DataReader.Read() ' open data reader connection
  
          ' retrieve Password number, balance amount and name information from database
          m_strPass = Convert.ToString(DataReader("Password"))
          m_decBalance = Convert.ToString(DataReader("Balance"))
          m_strName = Convert.ToString(DataReader("Name"))
  
          DataReader.Close() ' close data reader connection
          dbCon.Close() ' close database connection
      End Sub ' RetrieveAccountInformation
  
      Private Sub btnBalance_Click(sender As Object, e As EventArgs) Handles btnBalance.Click
          'Retrieve their account information
          RetrieveAccountInformation()
          Try
              MsgBox("You balance is " + " " + m_decBalance)
          Catch ex As Exception
              MsgBox(ex.Message)
          End Try
      End Sub
  End Class
  </code></pre>