Greetings
I have a little procedure that ensure Tracking numbers are correctly entered into a TEDIT.
(Two LETTERS, 9Digits, Two letters e.g.AA952800068US).
It works perfectly.
The only issue is that I am missing something simple as it only works when the CAPS-LOCK is on.
Changing the Charcase of the Tedit to Uppercase has no effect. Getting the user to constantly check his Caps-lock is not viable.
I have also tried using Uppercase, upcase, ansiuppercase etc to change the inputtext, to no avail.
The only option left is to add provision for lowercases in the IF statements, but I am busy fumbling it and would really like some help to ensure the characters entered ARE capitals even if the use has the caps-lock off.
(I assume setting the Uppercase changes in Charcase happens after the Keypress event fires in the program)
If any of my explaining makes any sense.
var
InputText: string;
begin
if not (Key in [#8, #9]) then // Allow Backspace and Tab
begin
InputText := TEdit(Sender).Text + Key;
// Check length
if Length(InputText) > 13 then
begin
Key := #0; // Prevent input if length exceeds 13
Exit;
end;
// Check format: Two letters, nine digits, two letters
if not ((Length(InputText) <= 2) and (Key in ['A'..'Z'])) and
not ((Length(InputText) > 2) and (Length(InputText) <= 11) and (Key in ['0'..'9'])) and
not ((Length(InputText) > 11) and (Length(InputText) <= 13) and (Key in ['A'..'Z'])) then
begin
Key := #0; // Prevent input if format is incorrect
end;
end;
end;
I am certain its right there before me and I am just overlooking it.
-Regards, Peter