I am using an Edit mask where a user can enter numbers in the following format 999/999/999/999, the user can not remove the forward slashes so he has to enter the information around them. What I want to do is to restrict the range of the numbers they can enter in the different parts of this,

so that until the first forward slash they are only allowed to enter a number between 1 to 500 . Between the 1st and 2nd forward slash 0 to 600 , 2rd and 3rd 0 to 600 and after the 3rd 0 to 600 as well. So if a number which is not whitin the range is entered i want a messagedialog to popup and say " please enter a number between...." and not allow the incorrect number to be entered. I have previously tried to put the restriction in the input mask of the editmask but it doesnt seem to work that way so i thought i would use the on change procedure. The code I have written is as follows but it does not work at all

procedure TForm1.MaskEdit1Change(Sender: TObject);

var

I : Integer;

begin

for I:=0 to 2 do

if MaskEdit1.Text>'500' then

showmessage('Incorrect number');

for I:=4 to 6 do

if MaskEdit1.Text ='600' then

showmessage('Incorrect number');

for I:=8 to 10 do

if MaskEdit1.Text='600' then

showmessage('Incorrect number');

for I:=11 to 13 do

if MaskEdit1.Text='600' then

showmessage('Incorrect number');

Hope I made the question clear enough. Thanks in Advance

if (v < 1) or (v > 600) or

(a < 1) or (a > 600) or

(b < 1) or (b > 600) or

(c < 1) or (c > 600)

then ShowMessage('incorrect number');

I was actually thinking along the lines of:

if (v < 1) or (v > 600) then begin

ShowMessage('Part one wrong');

end else if (a < 1) or (a > 600) then begin

ShowMessage('Part 2 wrong');

end else if (b < 1) or (b > 600) then begin

ShowMessage('Part 3 wrong');

end else if (c < 1) or (c > 600) then begin

ShowMessage('Part 4 wrong');

end else begin

// It's all valid

end;

Geoff M.