Pemisah ribuan saat input edit
//PEMISAH RIBUAN SAAT TEXT EDIT DIKETIK (Contoh sampai 1,000,000)
//---------------------------------------------------------------
//Event OnKeyPress di Edit1.text isikan :
if not (key in ['0'..'9',#8]) then
key:=#0;
// Saat angka diketik
// Contoh 1,000
if (Edit1.SelStart=3) and (not (key in [#8])) then
begin
edit1.Text:=copy(edit1.Text,1,1)+','+
copy(edit1.Text,2,1)+
copy(edit1.Text,3,1)+
copy(edit1.Text,4,1);
Edit1.SelStart:=5;
end;
// Contoh 10,000
if (Edit1.SelStart=5) and (not (key in [#8])) then
begin
edit1.Text:=copy(edit1.Text,1,1)+
copy(edit1.Text,3,1)+','+
copy(edit1.Text,4,1)+
copy(edit1.Text,5,1)+
copy(edit1.Text,6,1);
Edit1.SelStart:=7;
end;
// Contoh 100,000
if (Edit1.SelStart=6) and (not (key in [#8])) then
begin
edit1.Text:=copy(edit1.Text,1,1)+
copy(edit1.Text,2,1)+
copy(edit1.Text,4,1)+','+
copy(edit1.Text,5,1)+
copy(edit1.Text,6,1)+
copy(edit1.Text,7,1);
Edit1.SelStart:=8;
end;
// Contoh 1,000,000
if (Edit1.SelStart=7) and (not (key in [#8])) then
begin
edit1.Text:=copy(edit1.Text,1,1)+','+
copy(edit1.Text,2,1)+
copy(edit1.Text,3,1)+
copy(edit1.Text,5,1)+','+
copy(edit1.Text,6,1)+
copy(edit1.Text,7,1)+
copy(edit1.Text,9,1);
Edit1.SelStart:=8;
end;
// Saat Backspace di tekan
// Contoh 1,000
if (key=#8) and (edit1.selstart=5) then
begin
Edit1.Text:=copy(edit1.Text,1,1)+
copy(edit1.Text,3,1)+
copy(edit1.Text,4,1)+
copy(edit1.Text,5,1);
Edit1.SelStart:=5;
end;
// Contoh 10,000
if (key=#8) and (edit1.selstart=6) then
begin
Edit1.Text:=copy(edit1.Text,1,1)+','+
copy(edit1.Text,2,1)+
copy(edit1.Text,4,1)+
copy(edit1.Text,5,1)+
copy(edit1.Text,6,1);
Edit1.SelStart:=6;
end;
// Contoh 100,000
if (key=#8) and (edit1.selstart=7) then
begin
Edit1.Text:=copy(edit1.Text,1,1)+
copy(edit1.Text,2,1)+','+
copy(edit1.Text,3,1)+
copy(edit1.Text,5,1)+
copy(edit1.Text,6,1)+
copy(edit1.Text,7,1);
Edit1.SelStart:=7;
end;
// Contoh 1,000,000
if (key=#8) and (edit1.selstart=9) then
begin
Edit1.Text:=copy(edit1.Text,1,1)+
copy(edit1.Text,3,1)+
copy(edit1.Text,4,1)+','+
copy(edit1.Text,5,1)+
copy(edit1.Text,7,1)+
copy(edit1.Text,8,1)+
copy(edit1.Text,9,1);
Edit1.SelStart:=9;
end;
// Selesai
Nama : Rifaat
Kerjaan : Pekerja di BRI Kanwil Palembang
Hobi 1 : Buat program delphi
Hobi 2 : Nonton film fiksi ilmiah
Email 1 : ahmad_riffaat@bri.co.id
Email 2 : ahmad.rifaat@yahoo.co.id
HP : 0816-321-723-65
Random Articles
- Lazarus Release 2.2.2
- Kulgram : Instalasi Lazarus di Perangkat Berbasis ARM
- Contoh Unit Untuk Block Keyboard Keys,.,.,.,.
- Mengenal OXYGENE – Pascal For .NET
- Mendapatkan Direktori/Path dari suatu aplikasi
- Cek apakah program sudah berjalan?
- Lazarus Release 2.0.6
- ODBC on Windows 64 bit OS
- Mengaktifkan Return key in a TWebbrowser
- Simulasi ALT+TAB
Last Articles
Recent Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 2 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 2 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 3 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 3 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 3 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 11 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 11 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 11 years ago