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.56 MB
Time: 0.021 c
7-22424
Nik
2001-09-21 14:30
2002.01.08
When installing Pro, you give errors on drive C


6-22303
maxi
2001-10-11 18:03
2002.01.08
The DCOM client does not see the DCOM server on different machines.


14-22389
sudiv
2001-11-08 15:38
2002.01.08
CashFiesta


14-22329
Dima-k17
2001-11-03 15:12
2002.01.08
Delphi times are over?


6-22287
Andrei
2001-08-08 10:35
2002.01.08
Has anyone worked with WebSnap ????





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 Spanish 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