Thursday, July 4, 2013

Calculate your BOD


Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = ""
        Dim strYear() As String = {"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snack", "Horse", "Goat", "Monkey", "Chicken", "Dog", "Pig"}
        Dim strDOB As String = MaskedTextBox1.Text
        Dim intAge As Integer = Math.Floor(DateDiff(DateInterval.Month, DateValue(strDOB), Now()) / 12)
        Label1.Text = "Age : " & intAge

        Dim thisDate1 As Date = MaskedTextBox1.Text
        Label4.Text = "Date is " + thisDate1.ToString("MMMM dd, yyyy") + "."

        Dim value1 As String = ""
        Dim y As Integer = thisDate1.ToString("yyyy")
        Dim x As Integer = (1901 - y) Mod 12
        If x = 1 Or x = -11 Then
            value1 = strYear(0)
        ElseIf x = 0 Then
            value1 = strYear(1)
        ElseIf x = 11 Or x = -1 Then
            value1 = strYear(2)
        ElseIf x = 10 Or x = -2 Then
            value1 = strYear(3)
        ElseIf x = 9 Or x = -3 Then
            value1 = strYear(4)
        ElseIf x = 8 Or x = -4 Then
            value1 = strYear(5)
        ElseIf x = 7 Or x = -5 Then
            value1 = strYear(6)
        ElseIf x = 6 Or x = -6 Then
            value1 = strYear(7)
        ElseIf x = 5 Or x = -7 Then
            value1 = strYear(8)
        ElseIf x = 4 Or x = -8 Then
            value1 = strYear(9)
        ElseIf x = 3 Or x = -9 Then
            value1 = strYear(10)
        Else
            If x = 2 Or x = -10 Then
                value1 = strYear(11)
            End If
        End If

        Label1.Text = "Date is " + thisDate1.ToString("MMMM dddd") + " " + value1 + " Year."
    End Sub
End Class

No comments:

Post a Comment