Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
txtyear1 is a textbox that has the value of 2010
txtyear2 is a textbox that has the value of 2011
if (txtyear2.Text >= txtyear1.Text)

how do you make the condition above to work?
Posted
Updated 19-Dec-10 20:14pm
v5
Comments
Toniyo Jackson 20-Dec-10 2:12am    
What you want to check? length or value?

One example:

C#
if (Int16.Parse(txtyear2.Text) >= Int16.Parse(txtyear1.Text))
{
}


you should also check out Int16.TryParse or Convert.ToInt16
 
Share this answer
 
v2
Comments
TweakBird 20-Dec-10 2:26am    
Good One
Vigneshb6 20-Dec-10 2:29am    
nice
wolfsor 20-Dec-10 2:43am    
what's the difference between Int16 and Int32?
JF2015 20-Dec-10 3:15am    
The difference is the value range.
Int 16 -- (-32768 to +32787)
Int 32 -- (-2,147,483684 to +2,147,483683)
Int 64 -- (-9223372036854775808 to +9223372036854775807)

So, for normal years, int16 should be enough.
Anton Levshunov 20-Dec-10 4:16am    
My small remark about possible exception when string parse.
Try this,
if (Convert.ToInt32(txtyear2.Text) >= Convert.ToInt32(txtyear1.Text))
{
}
 
Share this answer
 
v2
try this

if (Convert.ToInt32(txtyear2.Text) >= Convert.ToInt32(txtyear1.Text))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900