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_HistoryToolStripBut ton_Click_ 1(object sender, EventArgs e)
{
try
{
Nullable<Decimal> id = null;
Nullable<Decimal> romid = null;
if (!string.IsNullOrEmpty(vIM IDToolStri pTextBox.T ext))
{
try
{
DataRow[] nDR1 = this.gmL_ITEMMSTRTableAdap ter1.GetDa taBy_vStoc kNumber(vI MIDToolStr ipTextBox. Text).Sele ct();
id = (decimal)nDR1[0]["ID"];
}
catch (Exception ex)
{
MessageBox.Show("Invalid Stock Number");
return;
}
}
if (!string.IsNullOrEmpty(thi s.vROMIDTo olStripTex tBox.Text) )
{
try
{
romid = (decimal)this.vROMIDToolSt ripTextBox .Text;
}
catch (Exception ex)
{
MessageBox.Show("ID must be Numberic");
return;
}
}
with a cannot convert STRING to DECIMAL.
How can I solve ?
--------------------------
private void fillBy_HistoryToolStripBut
{
try
{
Nullable<Decimal> id = null;
Nullable<Decimal> romid = null;
if (!string.IsNullOrEmpty(vIM
{
try
{
DataRow[] nDR1 = this.gmL_ITEMMSTRTableAdap
id = (decimal)nDR1[0]["ID"];
}
catch (Exception ex)
{
MessageBox.Show("Invalid Stock Number");
return;
}
}
if (!string.IsNullOrEmpty(thi
{
try
{
romid = (decimal)this.vROMIDToolSt
}
catch (Exception ex)
{
MessageBox.Show("ID must be Numberic");
return;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.