What am I missing ? (messing with dates) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

What am I missing ? (messing with dates)

TheJoyTheJoy Posts: 4Member
Hi,
I am trying to make a textbox(totalage) that display the number of days since the date inputed in another textbox(datestarted)

notes: -totalage display Clic for current date when empty
-dateplanted is auto filled on clic by syteme (format dd/mm/yy)

here's my code:

Private Sub NumberofDaysSince()

Dim tsTimeSpan As TimeSpan
Dim tNumberOfDays As Integer
Dim strMsgText As String

tsTimeSpan = Now.Subtract(datestarted.Text)
tNumberOfDays = tsTimeSpan.Days
strMsgText = tNumberOfDays.ToString()

If datestarted.Text = "Clic for current date" Then
Else : totalage.Text = strMsgText
End If
End Sub


I'm sure my error is stupid since i can't find it :P. and i'm sure you've noticed that i'm really new to this :) but i loooove it !!

Thank you verry much for you help !

Comments

  • TheJoyTheJoy Posts: 4Member
    NVM i found it... took the wrong way in the begining it came alone while rewrithing it..

    If datestarted.Text = "Clic for current date" Then
    Else
    Dim date1 As Date
    Dim date2 As Date
    Dim date3 As String
    date1 = datestarted.Text
    date2 = Now()
    date3 = (date2 - date1).Days.ToString
    totalage.Text = date3
    On Error Resume Next
    End If

    that easy :P not the best codes, but still it works !
Sign In or Register to comment.