Link to home
Start Free TrialLog in
Avatar of finance_teacher
finance_teacher

asked on

C# -- convert STRING to DECIMAL

The below "romid = (decimal)" fails
with a cannot convert STRING to DECIMAL.

How can I solve ?
------------------------------------------------------------------------------------
        private void fillBy_HistoryToolStripButton_Click_1(object sender, EventArgs e)
        {
            try
            {
                Nullable<Decimal> id = null;
                Nullable<Decimal> romid = null;

                if (!string.IsNullOrEmpty(vIMIDToolStripTextBox.Text))
                {
                    try
                    {
                        DataRow[] nDR1 = this.gmL_ITEMMSTRTableAdapter1.GetDataBy_vStockNumber(vIMIDToolStripTextBox.Text).Select();
                        id = (decimal)nDR1[0]["ID"];

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Invalid Stock Number");
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(this.vROMIDToolStripTextBox.Text))
                {
                    try
                    {
                        romid = (decimal)this.vROMIDToolStripTextBox.Text;

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("ID must be Numberic");
                        return;
                    }
                }
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial