Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to compare two decimal values

Status
Not open for further replies.

codecomm

Programmer
Joined
Feb 14, 2007
Messages
121
Location
US
I'm trying to compare two decimal values:

if ((decimal)(txtMain.Text) < decimal.Parse(.90))
{
//"Green"
}
else
{
"Red"
}

...and I keep getting the error of can't use "<" operand with decimals.
 
well...first of all, you've got the parameters a bit off. The Parse method takes a string. Also, you need to use the Parse statement to convert a string to decimal.

Try:

if(decimal.Parse(txtMain.Text) < (decimal).90)
{
...
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top