Minggu, 14 April 2013

Penggunaan Fungsi DateAdd Pada Microsoft Visual Basic 6.0

Apabila fungsi DateDiff digunakan untuk mengurangkan tanggal atau bulan atau tahun dari 2 buah tanggal, maka fungsi DateAdd digunakan untuk menambahkan tanggal atau bulan atau tahun.

Langkah - langkah penerapan fungsi DateAdd dalam program VB 6.0 :
·           Buka proyek Standard EXE yang baru.
·           Klik menu Project  =>  Components atau tekan tombol Ctrl + T pada keyboard atau klik kanan pada ToolBox, lslu pilih Components.
·           Centang Microsoft Windows Common Controls-2 6.0, lalu klik Apply lalu klik OK (perhatikan gambar di bawah)
 
 Gbr 1

Kemudian objek DTPicker akan muncul di ToolBox
 
 Gbr 2

·   Disain tampilan form seperti gambar berikut dengan menggunakan objek Label, TextBox dan CommandButton dan DTPicker dan Line.
 
 Gbr 3

·             Atur Properties masing - masing kontrol seperti dibawah ini :

Kontrol
Properties
Pengaturan
CommandButton1
Name        
Caption  
Font
Style
BackColor
Cmd_Hitung
&Hitung
MS Sans Serif, Bold, 10
1 - Graphical
&H00C0FFFF&
CommandButton2
Name        
Caption  
Font
Style
BackColor
Cmd_Keluar
&Keluar
MS Sans Serif, Bold, 10
1 - Graphical
&H00C0FFFF&
Label1
Caption

Font
ForeColor
BackColor
Mencari Selisih 2 Buah Tanggal Dengan Menggunakan Fungsi DateDiff
MS Sans Serif, Bold, 12
&H00FF0000&
&H0080FF80&
Label2
Caption
Font
ForeColor
BackColor
Tanggal Pertama   :
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label3
Caption
Font
ForeColor
BackColor
Tanggal Kedua     :
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label4
Caption
Font
ForeColor
BackColor
Selisih
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label5
Caption
Font
ForeColor
BackColor
atau
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label6
Caption
Font
ForeColor
BackColor
atau
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label5
Name
Caption
Font
ForeColor
BackColor
Lbl_SelisihHari
(dikosongkan)
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label5
Name
Caption
Font
ForeColor
BackColor
Lbl_SelisihBln
(dikosongkan)
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Label5
Name
Caption
Font
ForeColor
BackColor
Lbl_SelisihThn
(dikosongkan)
MS Sans Serif, Bold, 8
&H00000040&
&H0080FF80&
Line1
BorderColor
BorderWidth
&H008080FF&
2
Line2
BorderColor
BorderWidth
&H008080FF&
2
Line2
BorderColor
BorderWidth
&H008080FF&
2

Form1
Name
Caption
BackColor
Frm_CariSelisihTgl
Program Untuk Mencari Selisih 2 Buah Tanggal
&H0080FF80&


·           Klik menu View  =>  Code, lalu Copy Paste (copas) kode dibawah ini :

Private Sub Cmd_Keluar_Click()
End
End Sub
Private Sub Cmd_Tambah_Click()
Me.DTPicker2.Value = DateAdd("d", Me.txt_tgl.Text, Me.DTPicker1.Value)
Me.DTPicker3.Value = DateAdd("m", Me.txt_bln.Text, Me.DTPicker1.Value)
Me.DTPicker4.Value = DateAdd("yyyy", Me.txt_thn.Text, Me.DTPicker1.Value)
Me.txt_tgl.Text = ""
Me.txt_bln.Text = ""
Me.txt_thn.Text = ""
Me.txt_tgl.SetFocus
End Sub

·           Jalankan Program dengan cara menekan tombol F5 pada keyboard atau pilih menu Run  => Start
·           Hasilnya ketika program dijalankan

 Gbr 4

Gbr 5


Download Program Cari Selisih Tanggal-2  disini

Tidak ada komentar:

Posting Komentar

Pos kan komentar anda !