Converting Time to Double, or arithmetic with Time

gaborn415

New member
Joined
May 27, 2011
Messages
2
Programming Experience
Beginner
Hello all, this is my first post here so if I'm posting in the wrong area or the wrong way I hope the mods will fix it. Anyways glad to be here!
I'm a very new programmer just started with VB .NET a month ago and I was trying to come up with a simple time card app for my work. I have three date/time comboboxes on the form, two for time and one for date. For the time being I'm simply trying to figure out how to perform math on the time to determine time worked. Ideally I'd like to have a lunch time set as well so the equation should be something along the lines of how to figure out time worked minus lunch if applicable, but I'm running into a wall with this. I've been using VB .NET for dummies as my main reference and it was useful for getting started but I'm having a heck of a time finding out how to do this. I thought maybe I needed to convert to Double to perform the math? I've looked all over on line for this, but I'm seeing a lot of references to date but not much to time, perhaps I'm simply missing how the datetimepicker object and time is used in VB .NET? Any help even general information would be greatly appreciated as I'm mostly teaching myself.Thank you!
 
You can use - operator to subtract Date values, the result is a TimeSpan value. A date value represent a specific time of date and in VB you use the Date data type for this. Date data type also offers lots of other useful members to manipulate such values.
Date Data Type (Visual Basic)
TimeSpan Structure (System)
 
Back
Top