Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

Monopulation of numbers. Find similar branches


Socol   (2001-12-18 10:01) [0]

Hello!
Suppose there is a label1.caption: = "450"
if label1.caption> "500" then boton1.enabled: = true
else
boton1.enablad: = false;
if label1.caption> "1000" then boton1.enabled: = true
else
boton1.enablad: = false;
In the first case, everything turns out and in the second no.
Ie Delphi shields that 450> 1000 Ie she compares on the first digit how to avoid it so that she began to compare on the whole number?



Виктор Щербаков   (2001-12-18 10:04) [1]

Compare numbers, not their string representations.



Socol   (2001-12-18 10:06) [2]

it's like?



gek   (2001-12-18 10:07) [3]

Or compare them tag_i



Виктор Щербаков   (2001-12-18 10:15) [4]

if StrToInt (Label1.Caption)> StrToInt (Label2.Caption) then ...



Voron   (2001-12-18 13:19) [5]

Box1.Enabled: = StrToInt (Label1.Caption)> 500;
Like this. Only it is necessary to take into account that StrToInt will cause an exception if the string passed to it contains something other than numbers, well, there may still be a minus ahead.



Андрей Сенченко   (2001-12-18 13:45) [6]

>> Voron ©

If Label1.Caption can contain anything (and at the development stage it cannot be assumed that), then it’s better to use for conversion

StrToIntDef (St: string, Default: integer): LongInt



Voron   (2001-12-18 14:35) [7]

>> Andrey Senchenko ©

StrToIntDef in case of failure does not raise an exception, but returns Default
Suppose we have something like

I: = StrToIntDef (St, -1);

If St is equal to "-1" then does the function return -1 anyway, and then how do you know if it returns Default or the string representation of the whole from St?

StrToInt generates an exception in case of failure, it can be processed.
Best regards Voron



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top









Memory: 0.57 MB
Time: 0.039 c
1-22030
Andrey Senchenko
2001-12-18 12:49
2002.01.08
Form.OnCloseQuery - How to handle?


3-21950
Hermit
2001-12-05 11:38
2002.01.08
Implicitly Started Transactions


7-22450
fsp
2001-09-21 22:32
2002.01.08
Screwing programs in the systems tray.


7-22431
Pasha
2001-09-21 15:58
2002.01.08
How to remove from the sound card, the waveform.


3-21956
Sevostyanov Igor
2001-12-05 17:56
2002.01.08
Programmatically execute SHUTDOWN IMMEDIATE





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish