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
- Ngoding Pascal di REPL.IT
- Membuat kontrol db aware
- Seleksi baris DBGrid menggunakan event OnMouseMove
- Menyembunyikan file dalam gambar
- Kill Window Process
- Release: FastPlaz Super Mom v0.12.22
- Set default printer
- Random Password text
- Membuat DBNavigator dgn TAction
- Zoom-In and Zoom-Out Text in a TRichEdit (Undocumented feature)
Last Articles
- Project Group dalam Lazarus
- FastPlaz Database Explorer
- Release: FastPlaz Super Mom v0.12.22
- PascalClass #3: Web Development with Free Pascal
- Makna Pascal di Pascal Indonesia
- Kulgram : Instalasi Lazarus di Perangkat Berbasis ARM
- PascalClass #1: Analisa Database dan Machine Learning
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
- Mengenal OXYGENE – Pascal For .NET
- PascalTalk #5: UX: Research, Design and Engineer
Recent Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 3 months ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 months ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 months ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 1 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 8 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 8 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 8 years ago