Results 1 to 11 of 11

Thread: [RESOLVED] What's the best way to have the user enter a time?

  1. #1

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Resolved [RESOLVED] What's the best way to have the user enter a time?

    I've never really worked with values of time in VB before. I now have a program where the user needs to enter a value in hours and minutes.

    It's too keep track of how late someone shows up for work so I think I'd like the user to enter something like 1:22 for one hour and twenty two minutes.

    What controls, formats are best suited for using time ?

  2. #2
    Fanatic Member space_monkey's Avatar
    Join Date
    Apr 2005
    Location
    神と歩くこと
    Posts
    573

    Re: What's the best way to have the user enter a time?

    I've only had one app before that needed time by itself (no date attached) input, but what i used was the date/time picker set for time only. It seemed to work pretty well.
    Using VB6 or VB.net 2008 with .net 3.5
    "Life... death... either way I'll be confined to a small cubicle!" - Hermes Conrad

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What's the best way to have the user enter a time?

    Use a Datepicker control.

    Set the format to dtpTime

    Now, they do not have to enter a time. The can use the updown buttons to select.

    Normally, this is used to select a time of date, but as you want hours and minutes for this, it can be easily modified to suit your needs.

  4. #4

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Re: What's the best way to have the user enter a time?

    But I don't want them to enter a time, per se.

    It's more like an interval of time, say 15 mins, 20 mins, 1:23 mins and so on.

  5. #5

    Thread Starter
    Fanatic Member The_Grudge's Avatar
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    836

    Re: What's the best way to have the user enter a time?

    Maybe if I could get rid of the AM/PM part.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What's the best way to have the user enter a time?

    Quote Originally Posted by The_Grudge
    Maybe if I could get rid of the AM/PM part.
    Hold on. I'm making something for you.

  7. #7
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: What's the best way to have the user enter a time?

    Use a Masked Edit control

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What's the best way to have the user enter a time?

    If you don't want to go the datepickter route, then here is an example using a couple of textboxes and a couple of command buttons.
    Attached Files Attached Files

  9. #9
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: What's the best way to have the user enter a time?

    Quote Originally Posted by The_Grudge
    I've never really worked with values of time in VB before. I now have a program where the user needs to enter a value in hours and minutes.

    It's too keep track of how late someone shows up for work so I think I'd like the user to enter something like 1:22 for one hour and twenty two minutes.

    What controls, formats are best suited for using time ?

    If the user have to type in the time then go to A if the administartor does it then go to B

    A:
    Since the user have to type in the time he got to work i recomand you to NOT DO IT, you should have a clock in lbltime and when the user 'clook in' then your app should take a time stemp of that time and he is why:
    I build build a 'clook in' 'clook out' software to mange worker time for a shop, after a while the shop maneger realise that when a chasher came late (in 1:00 for instance) they typed (11:30) and liyed. right after i got that massage from the maneger, i want and made that the user will NOT asked what time but the app will take a time stemp.


    B: since an administrator will type in the time (or someone you can trust) you could simply use an inputbox
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  10. #10
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: [RESOLVED] What's the best way to have the user enter a time?

    You can use this code too:

    VB Code:
    1. Private Sub Form_Load()
    2. gettime
    3. End Sub
    4.  
    5. Public Function gettime()
    6. gettime = InputBox("Please indicate the exact time of user login:", "Exact Time", Time)
    7. If gettime = "" Then
    8. MsgBox "You Must Type The Time", vbExclamation, "!!!!!!!!"
    9. gettime
    10. Else
    11. MsgBox "User Loged in on " & gettime, vbInformation, "Loged Time"
    12. End If
    13. End Function
    1) If your post has been adequately answered please click in your post on "Mark Thread Resolved".
    2) If someone has been useful to you please show your respect by rating their posts.
    3) Please use [highlight="VB"] 'your code goes in here [/highlight] tags when posting code.
    4) Before posting your question, make sure you checked this links:
    MICROSOFT MSDN -- VB FORUMS SEARCH

    5)Support Classic VB - A PETITION TO MICROSOFT

    ___________________________________________________________________________________
    THINGS TO KNOW ABOUT VB: || VB Examples/Demos
    What are Classes?
    || -
    Where to place a sub/function?(global) || Webbrowser control

  11. #11
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    Re: [RESOLVED] What's the best way to have the user enter a time?

    Here's something...
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width