Comparing two numeric strings

phreaky

Regular
Joined
Dec 7, 2002
Messages
71
Location
Caracas, Venezuela
How can I compare two numeric string to see which one is bigger?, I mean, I have two strings submited by textboxes....I try to compare if sting a (14) is bigger than string B (9), but it keeps saying me B is bigger (if I just compare textbox1 < textbox2). How can I compare two strings by its numeric values?

I tried to use convert.toint16, but it says I give the string in bad format. How can I compare those???
 
(14) - is this what your string looks like? if so you need to take out the parenthesis.

Woulkd help if we saw the code for what you are trying to do
 
techmanbd said:
(14) - is this what your string looks like? if so you need to take out the parenthesis.

Woulkd help if we saw the code for what you are trying to do

No, the parenthesis were there ONLY to make tell an example of the string, my string is just a number.
 
If you do a check textbox1.Text > textbox2.Text it won't do a numeric '>' check, but a string check. I dont know how they work, but it could be that the starting character would be leading (like you get 1, 10, 11 .. 19, 2, 20, 21 .. 29, 3, 30, ... in some sort orders) That makes 1000 smaller than 9 but still bigger than 10.
If you want to make sure a numeric check is done, you must first convert all texts to numbers. Use int.parse(textbox.text) to convert the text to a number. For floating points you can use double.parse.
 
Back
Top