help pls i need someone that can help me when i enter the date of birth using the datetimepicker box it automatically compute the age and output in a textbox.text

Dim myCoolBirthday As Date = DateTimePicker1.Value.Date '// selected value from DateTimePicker.
        Dim currentDate As Date = Today '// value of current date.
        Dim myAge As Integer = currentDate.Year - myCoolBirthday.Year '// subtract years from current date.
        MsgBox("My age: " & myAge & vbNewLine & "Just don't tell anyone. :)") '// display age.

here is my code....
code for button..
Dim born, today As Integer
Dim now() As String
Dim now1 As String
now1 = Date.Today
now = now1.Split("/")
born = CInt(TextBox1.Text)
today = CInt(now(2))
born = today - born
TextBox2.Text = born

what i want is that i want to use the datetimepicker and it automatically compute the age in another textbox without clicking the button..

owww thank you again hehehe :)

i change the code to textbox2.text = myAge but the problem is if i change the year in datetimepicker it does not compute anymore the age

Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        Dim Age As Double = Math.Floor(DateDiff(DateInterval.Month, DateTimePicker1.Value, System.DateTime.Now) / 12)
        TextBox1.Text = "Your age is: " & Age
    End Sub

solved hehehe:)

here is my code....
code for button..
Dim born, today As Integer
Dim now() As String
Dim now1 As String
now1 = Date.Today
now = now1.Split("/")
born = CInt(TextBox1.Text)
today = CInt(now(2))
born = today - born
TextBox2.Text = born

what i want is that i want to use the datetimepicker and it automatically compute the age in another textbox without clicking the button..

I have modified your code slightly, but for future references arjen, please refrain from using Variables that relate to vb.net.
Example, you declared now and today, which are both used by vb.net to access certain values.

TextBox1.Text = DateTimePicker1.Value.Year
        Dim now1 As String = Date.Today
        Dim now() As String = now1.Split("/")
        Dim today As Integer = CInt(now(2))
        Dim born As Integer = Today - CInt(TextBox1.Text)
        TextBox2.Text = born

Textbox1.text=now.year - datetimepicker1.value.year

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.