Solved

Help! detect if label1.caption is less than label2.caption

Posted on 2003-11-30
2
587 Views
Last Modified: 2010-04-05
Ok heres wha i've got:

1 form
1 timer
label1
label2

On create timer 1 containing the following code adds '1' to label1.caption at a 3000 interval

If label1.caption < label2.Caption then label1.caption :=IntToStr(StrToInt(label1.caption+1);

(automatically another timer counts the number of messages on a mail server and the count is put in caption2)

This code is to stop the number in label1 exceeding label2. and if this happens there is a seperate piece of code which makes the whole process start over again.

It all works fine when

label1.caption = Between 1-9
label2.caption Between 1-9

But as soon as Label2 = more than 9 (i.e 10) it goes wrong because it is almost like timer 1 reads label2 as being 1 and not 10 and so starts back at 1 again because by now label1 will = 2/3/4//5 etc...

Using the above code how do i get timer 1 to only add '1' to label1 if this will not exceed label2 - and to get timer 1 to recognize that if label2 = 10 it it is 10 and not 1?????? therefore meaning that label2 is more than label1 so procced adding 1 to label1.

Hope this all maks sense!!!!


If you are able to help please provide full source code (its far better to spell it out than waste time going backwards and forwards)

Cheers

Harry.
0
Comment
Question by:harry_bela
2 Comments
 
LVL 5

Accepted Solution

by:
Darth_helge earned 300 total points
ID: 9844907
when you do this comparison you don't compare two numbers, you compare two strings.

If label1.caption < label2.Caption then label1.caption :=IntToStr(StrToInt(label1.caption+1);

so if you convert the two labelcaptions to numbers before you compare them it should work

If StrToInt(label1.caption) < StrToInt(label2.Caption) then label1.caption :=IntToStr(StrToInt(label1.caption+1);

hope this helps

helgesen
0
 

Author Comment

by:harry_bela
ID: 9845120
Hi helgesen,

I have taken your code an have improved it so thanks....

300 points coming your way.

Harry
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now