Thread: help
View Single Post
Old Nov 13th, 2006, 10:13 AM   #7
melbolt
Professional Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 254
Rep Power: 4 melbolt is on a distinguished road
here's one way to do it

vbnet Syntax (Toggle Plain Text)
  1. Public Class Form1
  2.  
  3. 'make a date variable
  4. Dim theDate As New DateTime
  5.  
  6.  
  7. ''' <summary>
  8. ''' form load handler
  9. ''' </summary>
  10. ''' <param name="sender"></param>
  11. ''' <param name="e"></param>
  12. ''' <remarks></remarks>
  13. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  14. 'get the date and time and put it in the variable
  15. theDate = Now
  16. End Sub
  17.  
  18.  
  19. ''' <summary>
  20. ''' button click handler
  21. ''' </summary>
  22. ''' <param name="sender"></param>
  23. ''' <param name="e"></param>
  24. ''' <remarks></remarks>
  25. Private Sub btnFullDateTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFullDateTime.Click
  26. 'with date and time
  27. MsgBox(theDate)
  28. End Sub
  29.  
  30. ''' <summary>
  31. ''' button click handler
  32. ''' </summary>
  33. ''' <param name="sender"></param>
  34. ''' <param name="e"></param>
  35. ''' <remarks></remarks>
  36. Private Sub btnTimeWithSeconds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimeWithSeconds.Click
  37. 'get the time portion of theDate and split it on the "." to remove the milliseconds, return the 0 index item of the string array
  38. MsgBox(theDate.TimeOfDay.ToString.Split(".")(0))
  39. End Sub
  40.  
  41.  
  42. ''' <summary>
  43. ''' button click handler
  44. ''' </summary>
  45. ''' <param name="sender"></param>
  46. ''' <param name="e"></param>
  47. ''' <remarks></remarks>
  48. Private Sub btnTimeWithoutSeconds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimeWithoutSeconds.Click
  49. 'displays the time with only hours and minutes
  50. MsgBox(theDate.TimeOfDay.ToString.Split(":")(0) & ":" & theDate.TimeOfDay.ToString.Split(":")(1))
  51. End Sub
  52. End Class


so as you can see, i basically just handled it like a string and parsed out the part of it i wanted in each case.

one button displays the full date and time

another button displays time only, with seconds

and the third button displays time only, without seconds



I'm not going to code the whole program, I'll leave the retrieval of the datetime object from the MSAccess Database up to you, but here is how you can manipulate it once you've retrieved it to get the value you desire out of it.


cheers :banana:
__________________
I have never let my schooling interfere with my education. -Mark Twain-

Xbox live gamertag: melbolt
melbolt is offline   Reply With Quote