Dalam kesempatan kali ini saya akan membuat aplikasi untuk membuat hari lahir dan nama intang.Untuk tutorial kita yang ini saya tidak akan membuat penjelasan secara rinci karena saya rasa anda sudah cukup paham dengan VB.Langsung ke TKP:
1.Tambahkan 3 buah label,3 buah text box,dan dua buah command button
2.desain posisi demi posisi seperti gambar di atas !
3.masukan kode berikut:
Private Sub Form_Load()
Command1.Enabled = False
End Sub
Private Sub Text1_Change()
If IsDate(Text1) Then
Command1.Enabled = True
Else
Command1.Enabled = False
End If
End Sub
Private Sub Command1_Click()
'MENCARI HARI LAHIR
Dim KodeHari As Byte
Dim Hari As String
KodeHari = Weekday(Text1)
Select Case KodeHari
Case 1: Hari = "Minggu"
Case 2: Hari = "Senin"
Case 3: Hari = "Selasa"
Case 4: Hari = "Rabu"
Case 5: Hari = "Kamis"
Case 6: Hari = "Jumat"
Case 7: Hari = "Sabtu"
End Select
Text2 = Hari
'MENCARI BINTANG
Dim Tg, Bl As Byte
Dim Btg As String
Tg = Day(Text1): Bl = Month(Text1)
If (Tg >= 21 And Bl = 3) Or (Tg <= 20 And Bl = 4) Then Btg = "ARIES"
If (Tg >= 21 And Bl = 4) Or (Tg <= 21 And Bl = 5) Then Btg = "TAURUS"
If (Tg >= 22 And Bl = 5) Or (Tg <= 21 And Bl = 6) Then Btg = "GEMINI"
If (Tg >= 22 And Bl = 6) Or (Tg <= 22 And Bl = 7) Then Btg = "CANCER"
If (Tg >= 23 And Bl = 7) Or (Tg <= 22 And Bl = 8) Then Btg = "LEO"
If (Tg >= 23 And Bl = 8) Or (Tg <= 22 And Bl = 9) Then Btg = "VIRGO"
If (Tg >= 23 And Bl = 9) Or (Tg <= 22 And Bl = 10) Then Btg = "LIBRA"
If (Tg >= 23 And Bl = 10) Or (Tg <= 21 And Bl = 11) Then Btg = "SCORPIO"
If (Tg >= 22 And Bl = 11) Or (Tg <= 21 And Bl = 12) Then Btg = "SAGITARIUS"
If (Tg >= 22 And Bl = 12) Or (Tg <= 20 And Bl = 1) Then Btg = "CAPRICORN"
If (Tg >= 21 And Bl = 1) Or (Tg <= 19 And Bl = 2) Then Btg = "AQUARIUS"
If (Tg >= 20 And Bl = 2) Or (Tg <= 20 And Bl = 3) Then Btg = "PISCES"
Text3 = Btg
End Sub
lalu RUN project dengan F5.dan lihat hasilnya
.::Warning::.
masukan tanggal dengan urutan berukut:
tanggal-bulan-tahun, contoh
21-03-1996
keren... :)
BalasHapus