º£Æ®³²Àº 13 À̶ó´Â ¼ýÀÚ¸¦ ³Ê¹«³ªµµ ½È¾îÇؼ 13À» ÀÔ·ÂÀÌ ¾ÈµÇ°í, 12A·Î ÀÔ·ÂÇØ ´Þ¶ó°í Çؼ ÀÛ¼ºÁßÀÔ´Ï´Ù. °æ¿ìÀÇ ¼ö°¡ ³Ê¹« ¸¹³×¿ä. ¾ÆÁ÷µµ ´Ù Àû¿ëÀ» ¸øÇß¾î¿ä. ¤Ð¤Ð
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); var iLn, pos, cnt, n: integer; str, st1: string; begin if K_NUMBER_MODE = 'NUMBER_MODE' then exit; // Ç¥ÁØ ¸ðµåÀÌ¸é ±×³É ¸®ÅÏ
if Key = #$61 then Key := #$41; // ¼Ò¹®ÀÚ a ´Â ´ë¹®ÀÚ A ·Î ¹Ù²Ù±â
iLn := Length(Edit1.Text); // ¼¼´ë ID ±æÀÌ pos := Edit1.SelStart; // ¼¼´ë ID Ä¿¼ À§Ä¡ cnt := StrLengthNoA(Edit1.Text);
if ( ((Key >= #$30) and (Key <= #$39))or(Key = 'A')or(Key = 'a') ) then begin // ------------------------------------------------------------------------- // A ÀԷ¿¡ ´ëÇÑ ÇÁ·Î¼¼½º // ------------------------------------------------------------------------- if (Key = 'A')or(Key = 'a') then begin if iLn < 2 then // ±æÀÌ°¡ 2º¸´Ù ÀÛÀ¸¸é ÀÔ·ÂÀ» Clear ÇÑ´Ù begin Key := #0; end else begin if pos < 2 then // ÇöÀç À§Ä¡°¡ 2º¸´Ù ÀÛÀ¸¸é ÀÔ·ÂÀ» Clear ÇÑ´Ù begin Key := #0; end else if pos = 3 then // ÇöÀç À§Ä¡°¡ 3ÀÎ °æ¿ì´Â A¸¦ ÀÔ·ÂÇÏ¸é ¾ÈµÈ´Ù begin Key := #0; end else begin if (iLn > pos) then // A ÀÔ·Â ¿ìÃø¿¡ A°¡ ÀÖÀ¸¸é A ÀÔ·Â °ÅºÎ begin st1 := Copy(Edit1.Text, pos+1, 1); if (st1 = 'A') or (st1 = 'a') then begin Key := #0; exit; end; end; str := Copy(Edit1.Text, pos-1, 2); if str <> '12' then Key := #0; end; end; end else // ------------------------------------------------------------------------- // ¼ýÀÚ ÀԷ¿¡ ´ëÇÑ ÇÁ·Î¼¼½º // ------------------------------------------------------------------------- begin if cnt >= 4 then // 12A12A´Â ±¦Âú´Ù, 12345 ´Ù¼¸ÀÚ¸®´Â ¾ÈµÈ´Ù begin Key := #0; end else begin if (iLn > pos) then // ÀÔ·Â ¼ýÀÚ ¿ìÃø¿¡ A°¡ ÀÖÀ¸¸é Àüü »èÁ¦ begin // --------------------------------------------------------------------- // A ÀÔ·Â ¿ìÃø¿¡ A°¡ ÀÖÀ¸¸é Àüü »èÁ¦ // --------------------------------------------------------------------- for n := pos+1 to iLn do begin st1 := Copy(Edit1.Text, n, 1); if (st1 = 'A') or (st1 = 'a') then begin Edit1.Text := ''; Key := #0; exit; end; end; end; // --------------------------------------------------------------------- // ¼ýÀÚ 1 ÀԷµǾúÀ» ¶§, ƯÁ¤ 13 ÀÔ·ÂÀº °ÅºÎ ÇÁ·Î¼¼½º // --------------------------------------------------------------------- if Key = #$31 then begin if iLn > 0 then begin if pos = 0 then begin str := Copy(Edit1.Text, 1, 1); if str = '3' then begin Key := #0; exit; end; end else if (iLn >= 3)and(cnt = 3)and(pos >= 3) then begin str := Copy(Edit1.Text, 1, 1); if str = '1' then begin Key := #0; exit; end; end; end; end; // --------------------------------------------------------------------- // ¼ýÀÚ 3 ÀԷµǾúÀ» ¶§, ƯÁ¤ 13 ÀÔ·ÂÀº °ÅºÎ ÇÁ·Î¼¼½º // --------------------------------------------------------------------- if Key = #$33 then begin if iLn > 0 then begin if pos = 1 then begin str := Copy(Edit1.Text, 1, 1); if str = '1' then begin Key := #0; exit; end; end else if (iLn >= 3)and(cnt = 3)and(pos >= 3) then begin str := Copy(Edit1.Text, pos, 1); if str = '1' then begin Key := #0; exit; end; end; end; end; end; end; end else begin if Key = char(VK_BACK) then // ¹é½ºÆäÀ̽º´Â »ç¿ëµÇ¾î¾ß ÇÑ´Ù begin if (pos > 0) and (iLn > pos) then // A ÀÔ·Â ¿ìÃø¿¡ A°¡ ÀÖÀ¸¸é Àüü »èÁ¦ begin // --------------------------------------------------------------------- // A ÀÔ·Â ¿ìÃø¿¡ A°¡ ÀÖÀ¸¸é Àüü »èÁ¦ // --------------------------------------------------------------------- for n := pos+1 to iLn do begin st1 := Copy(Edit1.Text, n, 1); if (st1 = 'A') or (st1 = 'a') then begin Edit1.Text := ''; Key := #0; exit; end; end; end; end else Key := #0; end; end;
>> 1. °³¹ß/½ÇÇà Ç÷§Æû >> (1) OS : Win10 >> (2) °³¹ßÅø : XE8 >> (3) »ç¿ë Database : >> >> 2. °³¹ß ÁßÀÎ ÇÁ·Î±×·¥ >> ¼ýÀÚ ¹× A,a¸¸ ÀÔ·Â ¹æ½Ä >> >> 3. Áú¹® ³»¿ë >> Edit¿¡ ¼ýÀÚ(0~9), A, a¸¸ ÀԷ¹޴ ÇÁ·Î±×·¥ÀÔ´Ï´Ù. >> A(¶Ç´Â a)´Â 12¼ýÀÚµÚ¿¡¸¸ ÀÔ·ÂÀÌ °¡´ÉÇÏ°Ô ÇÏ·Á¸é ¾î¶»°Ô ÇØ¾ß Çϳª¿ä? >> procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); >> var >> iLn: integer; >> begin >> if ( ((Key >= #$30) and (Key <= #$39))or(Key = 'A')or(Key = 'a') ) then >> begin >> >> end else >> begin >> Key := #0; >> end; >> end; >> Á¶¾ðÀ» ±¸Çغ¾´Ï´Ù. >>
|