Timespan help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rlegg369
    New Member
    • Sep 2006
    • 1

    Timespan help

    Hi,
    I am pretty new to VB.NET. I am writing a program for keeping track of hours worked on different projects.
    I need to save the values of a date and time selected by the user. Because they can be edited, I can't use DTP.DATE.NOW. Instead I use datetimepicker controls to allow the user to select the date and time. I place the values in a text box.

    TxtBegTime.Text =DtpDate.Value. ToShortTimeStri ng
    TxtBegDate.text = DtpDate.Value.T oShortDateStrin g

    When the user adds (accepts) the time sheet, the data is written to a text file. using the value of the text box field ie.

    PrintLine( 3, txtbegtime.text )

    When the time sheet is updated at a later time to get the end time, the file is accessed, and the text boxes in the time sheet form are filled from the text file.

    The user can then choose the date and time of completion, once again the dtp values are written to the appropriate text boxes in the time sheet form

    TxtEndTime.Text =DtpDate.Value. ToShortTimeStri ng
    TxtEndDate.text = DtpDate.Value.T oShortDateStrin g

    I now want to determine the time span between the beginning time and date and the ending time and date. I would like to useTimeSpan to do this, but the data captured is not in date format. Is it possible to take the text saved and re-format it to a date that can be used to get the elapsed time using timespan, or am I going about this in the wrong way?

    I know I can create an algorithim to seperate day, hour,min,sec from the strings and make the calculations manually, but I don't want to do that if it is not necessary.
    Any help would be appreciated.
    Thanks!
Working...