Kali ini saya akan berbagi ilmu tentang cara membuat Aplikasi untuk mengetahui zodiak seseorang dengan menggunakan Visual Basic 6.0
Langkah pertama buatlah Project dengan komponen :
1 DTPicker dan 3 TextBox
Berikan nama masing - masing komponen :
DTPicker1 = dtpLahir
Text1 = txtHari
Text2 = txtBintang
Text3 = txtShio
Lihat gambar dibawah :
Call dtpLahir_Change
End Sub
Dim c As String
Dim d As String
Dim tgl As Integer, bln As Integer, thn As Integer
tgl = Format(dtpLahir.Value, "dd")
bln = Format(dtpLahir.Value, "MM")
thn = Format(dtpLahir.Value, "yyyy")
'hari
Select Case Weekday(dtpLahir.Value)
Case 1: a = "Minggu"
Case 2: a = "Senin"
Case 3: a = "Selasa"
Case 4: a = "Rabu"
Case 5: a = "Kamis"
Case 6: a = "Jum'at"
Case 7: a = "Sabtu"
End Select
Select Case DateDiff("d", CDate("1/1/1900"), dtpLahir.Value) Mod 5
Case 0: b = "Pahing"
Case 1: b = "Pon"
Case 2: b = "Wage"
Case 3: b = "Kliwon"
Case 4: b = "Legi"
End Select
'bintang
Select Case bln
Case 1: c = IIf(tgl <= 19, "Capricorn", "Aquarius")
Case 2: c = IIf(tgl <= 19, "Aquarius", "Pisces")
Case 3: c = IIf(tgl <= 20, "Pisces", "Aries")
Case 4: c = IIf(tgl <= 20, "Aries", "Taurus")
Case 5: c = IIf(tgl <= 21, "Taurus", "Gemini")
Case 6: c = IIf(tgl <= 21, "Gemini", "Cancer")
Case 7: c = IIf(tgl <= 21, "Cancer", "Leo")
Case 8: c = IIf(tgl <= 21, "Leo", "Virgo")
Case 9: c = IIf(tgl <= 22, "Virgo", "Libra")
Case 10: c = IIf(tgl <= 23, "Libra", "Scorpio")
Case 11: c = IIf(tgl <= 22, "Scorpio", "Sagitarius")
Case 12: c = IIf(tgl <= 22, "Sagitarius", "Capricorn")
End Select
'shio
Select Case thn - ((Int(thn / 12) * 12))
Case 0: d = "Kera"
Case 1: d = "Ayam"
Case 2: d = "Anjing"
Case 3: d = "Babi"
Case 4: d = "Tikus"
Case 5: d = "Lembu"
Case 6: d = "Macan"
Case 7: d = "Kelinci"
Case 8: d = "Naga"
Case 9: d = "Ular"
Case 10: d = "Kuda"
Case 11: d = "Domba"
End Select
txtHari.Text = a & " " & b
txtBintang.Text = c
txtShio.Text = d
End Sub
Langkah pertama buatlah Project dengan komponen :
1 DTPicker dan 3 TextBox
Berikan nama masing - masing komponen :
DTPicker1 = dtpLahir
Text1 = txtHari
Text2 = txtBintang
Text3 = txtShio
Lihat gambar dibawah :
Isikan kode :
Private Sub Form_Load()
dtpLahir.Value = NowCall dtpLahir_Change
End Sub
Private Sub dtpLahir_Change()
Dim a As String, b As StringDim c As String
Dim d As String
Dim tgl As Integer, bln As Integer, thn As Integer
tgl = Format(dtpLahir.Value, "dd")
bln = Format(dtpLahir.Value, "MM")
thn = Format(dtpLahir.Value, "yyyy")
'hari
Select Case Weekday(dtpLahir.Value)
Case 1: a = "Minggu"
Case 2: a = "Senin"
Case 3: a = "Selasa"
Case 4: a = "Rabu"
Case 5: a = "Kamis"
Case 6: a = "Jum'at"
Case 7: a = "Sabtu"
End Select
Select Case DateDiff("d", CDate("1/1/1900"), dtpLahir.Value) Mod 5
Case 0: b = "Pahing"
Case 1: b = "Pon"
Case 2: b = "Wage"
Case 3: b = "Kliwon"
Case 4: b = "Legi"
End Select
'bintang
Select Case bln
Case 1: c = IIf(tgl <= 19, "Capricorn", "Aquarius")
Case 2: c = IIf(tgl <= 19, "Aquarius", "Pisces")
Case 3: c = IIf(tgl <= 20, "Pisces", "Aries")
Case 4: c = IIf(tgl <= 20, "Aries", "Taurus")
Case 5: c = IIf(tgl <= 21, "Taurus", "Gemini")
Case 6: c = IIf(tgl <= 21, "Gemini", "Cancer")
Case 7: c = IIf(tgl <= 21, "Cancer", "Leo")
Case 8: c = IIf(tgl <= 21, "Leo", "Virgo")
Case 9: c = IIf(tgl <= 22, "Virgo", "Libra")
Case 10: c = IIf(tgl <= 23, "Libra", "Scorpio")
Case 11: c = IIf(tgl <= 22, "Scorpio", "Sagitarius")
Case 12: c = IIf(tgl <= 22, "Sagitarius", "Capricorn")
End Select
'shio
Select Case thn - ((Int(thn / 12) * 12))
Case 0: d = "Kera"
Case 1: d = "Ayam"
Case 2: d = "Anjing"
Case 3: d = "Babi"
Case 4: d = "Tikus"
Case 5: d = "Lembu"
Case 6: d = "Macan"
Case 7: d = "Kelinci"
Case 8: d = "Naga"
Case 9: d = "Ular"
Case 10: d = "Kuda"
Case 11: d = "Domba"
End Select
txtHari.Text = a & " " & b
txtBintang.Text = c
txtShio.Text = d
End Sub
Jalankan program, dan hasilnya seperti gambar dibawah :
Untuk yang malas ngetik Source Codenya, silahkan download Aplikasinya di sini.
0 komentar:
Post a Comment