Hello, I have a small application that reads employee registration numbers from a barcode on a badge, the registration number is saved in the bank with 12 characters, example: 000000002014, and the barcode is generated: 0000000020145 EAN13 format, in form I have a radiogroup with the manual and automatic option, if you enter 0201 and click on save it is completed with 0 on the left until the correct registration is formed, if you type the 12 characters it reads directly and if you see the 13 in the barcode it is removed the digit leaving only the 12. my problem is reading the barcode, below is the code I use in the edit's onkeydown, however if I press crtl+v it works, but if I read the barcode with the scanner comes with 12 digits and does not work.
procedure TFrmPrincipal.Edit1KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
var
registration: string;
begin
if RadiobuttonAutomatic.Checked then
begin
if Key = VK_RETURN then
begin
registration := Edit1.Text;
if Length(registration) < 12 then
begin
registration:= StringOfChar('0', 12 - Length(registration)) + registration;
ProcessBarCode(registration);
end;
if Length(registration) = 12 then
begin
registration:= StringOfChar('0', 12 - Length(registration)) + registration;
ProcessBarCode(registration);
end;
if Length(registration) > 12 then
begin
registration := ExtractRegistrationToEAN13(registration);
ProcessBarCode(registration);
end;
end;
end;
end;