• Buat Projek Baru
  • Desain tempilan seperti ini:
Desain
  • Pada Tombol hitung ketikkan kode berikut:

    Dim a As String
    Dim b As String
    Dim c As String
    
    a = TextBox3.Text
    b = TextBox2.Text
    c = TextBox1.Text
    
    Dim DOB As New DateTime(a, b, c)
    
    Dim Years As Integer = DateDiff(DateInterval.Year, DOB, Now) - 1
    Dim Months As Integer = DateDiff(DateInterval.Month, DOB, Now) Mod 12
    Dim days As Integer = DateDiff(DateInterval.Day, DOB, Now) Mod 30 - 10
    TextBox4.Text = Years & " Tahun, " & Months & " Bulan "
    
  • Jalankan, lalu inputkan tanggal bulan dan tahun lahir.
Hitung Usia


 
Top