What am I missing ? (messing with dates)

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 !


  • 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
    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.

Howdy, Stranger!

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


In this Discussion