Solved

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

Posted on 2003-11-30
2
573 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

16 Experts available now in Live!

Get 1:1 Help Now