Solved

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

Posted on 2003-11-30
2
617 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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