[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 ?
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.
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.
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.
Re: What's the best way to have the user enter a time?
Maybe if I could get rid of the AM/PM part.
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.
Re: What's the best way to have the user enter a time?
Use a Masked Edit control
Pradeep :)
1 Attachment(s)
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.
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
Re: [RESOLVED] What's the best way to have the user enter a time?
You can use this code too:
VB Code:
Private Sub Form_Load()
gettime
End Sub
Public Function gettime()
gettime = InputBox("Please indicate the exact time of user login:", "Exact Time", Time)
If gettime = "" Then
MsgBox "You Must Type The Time", vbExclamation, "!!!!!!!!"
gettime
Else
MsgBox "User Loged in on " & gettime, vbInformation, "Loged Time"
End If
End Function
1 Attachment(s)
Re: [RESOLVED] What's the best way to have the user enter a time?