473,287 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

select time (hours,minutes,second) in updown arrow

115 100+
how can i select time (hours,minutes,second) in updown arrow buttons in VB.NET.

as we have current time displayed in date and time properties in our system.

in date and time properties, while we press updown arrown, that will change only hour first, and if we select the minutes and press updown arrow, minutes will get changed and if we select the seconds and press updown arrow, it will change the seconds.
if we use numericupdown tool, i can give only hour, or minutes, or second. i cant combine all the three hours:minutes:second in that numericupdown arrow.
if i use domainupdown tool, i dont know how to select hours,minutes seperately inside a single updown.
if you have any idea how to do this please help me. and if you can give an example that will be a great help for me.
thanks in advance.
Jun 29 '07 #1
12 16038
Wing
28
I recently did this using 3 Numeric Up Down tools then combining them.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim pTime as DateTime
  3. pTime = udHour.Value & ":" & udMin.Value & ":" udSec.Value
  4. pTime = pTime.ToLongTimeString
Hope this helps you out.
Jun 29 '07 #2
remya1000
115 100+
thank for your help. one more dought,
this means 3 numericupdown should be there and seperately we need to select the hours in first numericupdown, minutes in secong numericupdown and so on. and we will combine them.
can we do this in a single one, as we have in date and time properties...
we have hh:mm:ss in one box and if we select the hours, then we can increment only hours and if we select minutes then increment that and so on...

if you have anyidea how to do this plesae help me.
thanks in advance.
Jun 29 '07 #3
Wing
28
Not quite sure about that. I was hoping that the DateTimePicker was going to let me do this but I didn't see anyway to adjust time on the DateTimePicker so I just created my own Time Modifier.
Jun 29 '07 #4
remya1000
115 100+
i just tried using datetimepicker and i can display time, but the formate is like 12:00:00 am to 11:59:59 pm is the whole day.

DateTimePicker1.Format = DateTimePickerFormat.Time
DateTimePicker1.ShowUpDown = True

and i change the property format=time
this will display time.

but i need to display time in format from 00:00:00 to 23:59:59. i dont need to seperate time by using am/pm.

if you have any idea plesae help me.
thanks in advance.
Jun 29 '07 #5
remya1000
115 100+
heay i can make it display by using datetimepicker.
i got this help from internet.

i placed a datetimepicker, and in properties, i changed
showupdown = true
format = custom
custom format = HH:mm:ss
and while running the program, i can set the time.

can we set like this.....
so now hours values will be from 00 to 23. so when it reach 23, if we press up arrow the value should not more. then only, if we press down arrow only the value should change. can we set like that.
if you have anyidea how to do that please help me.
thank in advance and thanks for the help.
can we do in this way in datetimepicker
Jun 29 '07 #6
Wing
28
Found it - In the DateTimePicker Properties set Format to Custom and CustomFormat = HH:MM:ss and you will get what I think you need.
Jun 29 '07 #7
Wing
28
Not sure if you need this as well but I just found that DateTimePicker.Value still passes the AM and PM value even though you are using the 24 Hour Format. In order to display your value as 24 Hour format you will need to use the following.

Format(DateTimePicker1.Value, "HH:mm:ss")
Jun 29 '07 #8
remya1000
115 100+
whether i can set the datetimepicker as this.
now if we press up arrow, the value will increment from 0 to 23 and when it reach 23, it again starts from 0 and go on....
i need to set it as, if i press up arrow i need to increment the value from 0 to 23. and when it reach 23 it should stop. it should not rotate again from 0 to 23. once it reach 23, if we need to select something else we need to press down arrow. and if i press down arrow it should decrement the values. and once it reach 0 it should not start again from 23 to 0.
whether i can set the values like this in datetimepicker.
if you have any idea please let me know.
thanks in advance.
Jul 3 '07 #9
remya1000
115 100+
Expand|Select|Wrap|Line Numbers
  1. Private prevHour As Integer
  2.  
  3. If DateTimePicker1.Value.Hour = 23 Then
  4.             If prevHour = 0 Then
  5.                 DateTimePicker1.Value = DateTimePicker1.Value.AddHours(1)
  6.             End If
  7.         End If
  8.         If DateTimePicker1.Value.Hour = 0 Then
  9.             If prevHour = 23 Then
  10.                 DateTimePicker1.Value = DateTimePicker1.Value.AddHours(-1)
  11.             End If
  12.         End If
  13.         prevHour = DateTimePicker1.Value.Hour

when i give this code, when the hours value reach 23 and if we press uparrow, it wont rotate from 0-23 as i need. and when hour value reach 0 and if we press down arrow, it wont rotate from 23-0 as i need.
likewise i need to set it for minutes and for seconds.
i need to set it as, if i press up arrow i need to increment the minutes value from 0-59. and when it reach 59 it should stop. it should not rotate again from 0 to 59. once it reach 59, if we need to select something else we need to press down arrow. and if i press down arrow it should decrement the values. and once it reach 0 it should not start again from 59 to 0. like wise as we set for hour (the values should not rotate), sameway i need to set for minutes and for seconds.
whether i can set the values like this in datetime picker.
if you have any idea please let me know.
thanks in advance.
Jul 5 '07 #10
remya1000
115 100+
its working by using this code.....

Expand|Select|Wrap|Line Numbers
  1. Private oldTime As DateTime
  2.  
  3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.         oldTime = DateTimePicker1.Value
  5.     End Sub
  6.  
  7.     Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
  8.         Dim newTime As DateTime = DateTimePicker1.Value
  9.         Dim hr As Integer = newTime.Hour
  10.         Dim min As Integer = newTime.Minute
  11.         Dim sec As Integer = newTime.Second
  12.  
  13.         If (oldTime.Hour = 23 AndAlso newTime.Hour = 0) OrElse (oldTime.Hour = 0 AndAlso newTime.Hour = 23) Then
  14.             hr = oldTime.Hour
  15.         End If
  16.         If (oldTime.Minute = 59 AndAlso newTime.Minute = 0) OrElse (oldTime.Minute = 0 AndAlso newTime.Minute = 59) Then
  17.             min = oldTime.Minute
  18.         End If
  19.         If (oldTime.Second = 59 AndAlso newTime.Second = 0) OrElse (oldTime.Second = 0 AndAlso newTime.Second = 59) Then
  20.             sec = oldTime.Second
  21.         End If
  22.         If hr <> newTime.Hour OrElse min <> newTime.Minute OrElse sec <> newTime.Second Then
  23.             DateTimePicker1.Value = DateTime.Now.Date.Add(New TimeSpan(hr, min, sec))
  24.         End If
  25.         oldTime = DateTimePicker1.Value
  26.  
  27.     End Sub
Jul 5 '07 #11
Hi

what it is mean udHour ? udSec and uDMIN
Dec 30 '15 #12
zmbd
5,501 Expert Mod 4TB
mellouljonathan:
This is a very old thread (9 years) and Mr. Wing has not been active on this site for a very long time.

If you will take a very careful look, you notice that Wing has stated that three Up/Down tools were used, then by inference, in the code these were named "udHour", "udMin" and "udSec" and the value of these controls are being returned to the variable pTime which is then formatted..

If you are having problems with a similar situation, please start a new thread. For context, you can include a link to this thread in your question. You should take a moment to review our FAQ on how to ask a question for some pointers on what to include.
Dec 30 '15 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Targa | last post by:
I have a form field which displays a time in the format 5:30 PM - this time is selected from a previous page. I need to add a function to increment or deincrement the time by clicking up/down...
9
by: ME | last post by:
can someone tell me how to make this first one work??, located here: http://javascript.about.com/library/scripts/blshowdatetime.htm#examplesource This second one, well, dreamweaver eats the code,...
4
by: Andrew Poulos | last post by:
How do I convert a length of time, measured in seconds, into a "point in time" type time interval or what's represented as: time (second,10,2) The format is: PS]] where: y: The number of...
4
by: flupke | last post by:
Is there an easy to convert following hour notation hh:mm to decimals? For instance 2 hours and 30 minutes as 2:30 to 2,50 I don't really know where to search for this kind of conversion. ...
6
by: Michael Bulatovich | last post by:
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time",...
6
by: Mark Reed | last post by:
Hi Guru's, I have created a database to monitor hours I have worked as our payroll department are so crap. I work nights most of the time but occasionally I have to work on days. Between the hours...
3
by: Stephen Chaplin | last post by:
I'm summing up time spent on jobs over a week, some of these jobs last greater than 24 hours and when access sums these up it appears that it starts again at 00:00 once it gets past 23:59. Is it...
2
by: jayender.vs | last post by:
Hi, I need to display the time in combo box like the one we have it in Wndows 2000. we can change the time using the arrow.. it looks like this: 4:40:54 PM in a combo box . i need to do it...
7
by: WorldIsEnding | last post by:
Hey, Im having trouble with converting a Numeric value (such as a single digit number like 1 or 5) into a time format. I need to convert a number entered into a variable into Hours on the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.