Kali ini saya akan memberikan souce code untuk program jam digital dengan tampilan seperti berikut
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFUtama *FUtama;
void datahari(void)
{
TDateTime dtHari;
int intHari;
String strHari;
dtHari = Date();
intHari = DayOfWeek(dtHari);
switch(intHari)
{
case 1 : strHari = "Minggu - ";
break;
case 2 : strHari = "Senin - ";
break;
case 3 : strHari = "Selasa - ";
break;
case 4 : strHari = "Rabu - ";
break;
case 5 : strHari = "Kamis - ";
break;
case 6 : strHari = "Jumat - ";
break;
case 7 : strHari = "Sabtu - ";
}
FUtama->Label2->Caption = strHari + DateToStr(dtHari);
}
//---------------------------------------------------------------------------
__fastcall TFUtama::TFUtama(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFUtama::Timer1Timer(TObject *Sender)
{
Label1->Caption = Time();
}
//---------------------------------------------------------------------------
void __fastcall TFUtama::FormShow(TObject *Sender)
{
datahari();
Label1->Caption = TimeToStr(Time());
}
//---------------------------------------------------------------------------
Semoga bermanfaat buat teman-teman yang lagi belajar :)
0 komentar:
Posting Komentar