Arsip: If..then pada events koq ga bisa?

more 17 years ago
wiseguy1997
Para sahabat Dephi-id, sy ada masalah spt ini:
Pada events OnChange di DirectoryListBox1
procedure TForm1.DirectoryListBox1OnChange(Sender: TObject);
begin
Label6.Caption:='DirectoryListBox berubah';
end;
kemudian aq pengin buat prosedur OnClick pd Button1 spt:
procedure TForm1.Buttton1OnClick(Sender: TObject);
begin
if DirectoryListBox1OnChange(DirectoryListBox1) then
begin
Label6.Caption:='DirectoryListBox tadi berubah lho...';
Form1.color:=clBlue;
end
else
Label6.Caption:='DirectoryListBox tidak berubah sama sekali';
end;
Tp knp ko keluar error: Type expression must be BOOLEAN. Mohon bantuannya.
Atas tanggapannya terima kasih.

more 17 years ago
DelphiExpert
DirectoryListBox1OnChange adalah sebuah procedure, bukan function!
procedure TForm1.DirectoryListBox1OnChange(Sender: TObject);
begin
Label6.Caption:='DirectoryListBox berubah';
end;
ya jelas saja muncul error :mrgreen:
more 17 years ago
mat_koder
di kode anda ada testing conditional sbb:
" if DirectoryListBox1OnChange(DirectoryListBox1) then "
sedangkan perintah : DirectoryListBox1OnChange(DirectoryListBox1) kan tidak menghasilkan return value ( itu adalah procedure bukan function ).
sementara Delphi menghendaki if .. then adalah sbb:
if <statement result =True> then
.. bla-bla
nah anda tau sekarang bukan kenapa error?
apa ngga sebaiknya kode anda begini:
var
DirectoryBerubah: Boolean;// global var yg menunjukkan directory berubah apa ngga
procedure TForm1.DirectoryListBox1OnChange(Sender: TObject);
begin
DirectoryBerubah:=True;;
end;
procedure TForm1.Buttton1OnClick(Sender: TObject);
begin
if DirectoryBerubah = True then
begin
Label6.Caption:='DirectoryListBox tadi berubah lho...';
Form1.color:=clBlue;
end
else
Label6.Caption:='DirectoryListBox tidak berubah sama sekali';
end;
DirectoryBerubah := False; // reset var ini lagi

more 17 years ago
wiseguy1997
@mat_koder: di kode anda ada testing conditional sbb: " if DirectoryListBox1OnChange(DirectoryListBox1) then " sedangkan perintah : DirectoryListBox1OnChange(DirectoryListBox1) kan tidak menghasilkan return value ( itu adalah procedure bukan function ). sementara Delphi menghendaki if .. then adalah sbb: if <statement result =True> then .. bla-bla nah anda tau sekarang bukan kenapa error? apa ngga sebaiknya kode anda begini:Oh iya Mas mat_koder,.... Trima kasih,kenapa koq ga terpikir olehku koding spt diatas :mrgreen: Dah ta coba dan itu sukses. Makasih banyak. Semoga ini juga bermanfaat bagi yang lainvar DirectoryBerubah: Boolean;// global var yg menunjukkan directory berubah apa ngga procedure TForm1.DirectoryListBox1OnChange(Sender: TObject); begin DirectoryBerubah:=True;; end; procedure TForm1.Buttton1OnClick(Sender: TObject); begin if DirectoryBerubah = True then begin Label6.Caption:='DirectoryListBox tadi berubah lho...'; Form1.color:=clBlue; end else Label6.Caption:='DirectoryListBox tidak berubah sama sekali'; end; DirectoryBerubah := False; // reset var ini lagi
more ...
- Pages:
- 1
reply |
Report Obsolete
AI Forward

🚀 We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now:
https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD
Last Articles
Last Topic
- PascalTalk #6: (Podcast) Kuliah IT di luar negeri, susah gak sih?
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #5: UX: Research, Design and Engineer
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #4: Obrolan Ringan Seputar IT
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #2: Membuat Sendiri SMART HOME
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #3: RADically Fast and Easy Mobile Apps Development with Delphi
by LuriDarmawan in Tutorial & Community Project more 4 years ago - PascalTalk #1: Pemanfaatan Artificial Intelligence di Masa Covid-19
by LuriDarmawan in Tutorial & Community Project more 4 years ago - Tempat Latihan Posting
by LuriDarmawan in OOT more 5 years ago - Archive
- Looping lagi...
by idhiel in Hal umum tentang Pascal Indonesia more 12 years ago - [ask] koneksi ke ODBC user Dsn saat runtime dengan ado
by halimanh in FireBird more 12 years ago - Validasi menggunakan data tanggal
by mas_kofa in Hal umum tentang Pascal Indonesia more 12 years ago
Random Topic
- ospek
by Alfando in OOT more 16 years ago - VCL dan Library gratis!
by DelphiExpert in Tip n Trik Pemrograman more 17 years ago - ari Tempat Kursus
by NiceDream in OOT more 17 years ago - [ASK] Cara Membuat Aplikasi Meluncurkan Aplikasi Lain
by yudiwidiawan in Tutorial & Community Project more 14 years ago - Absen dengan barcode
by nasbms in Tutorial & Community Project more 13 years ago - bikin preview mata uang gmn?
by skyblue in Tip n Trik Pemrograman more 18 years ago - SP Yang memakai Parameter
by umarbakri in MySQL more 18 years ago - Posisi Alligment Center di TEDIT
by DeulleDo-X in Hal umum tentang Pascal Indonesia more 17 years ago - Ngisi karakter /,",',: ato \ dan sejenisnya ga bisa di
by wiseguy1997 in Tip n Trik Pemrograman more 17 years ago - compact db,compress exe
by ImanD in Enginering more 18 years ago