Solved

visual studio dropdownlist calculate time values

Posted on 2014-02-14
4
216 Views
Last Modified: 2014-02-14
NOW
5:00 PM
5:15 PM
5:30 PM
5:45 PM
6:00 PM
etc

I want this to stop at 11:45 PM

here is existing code (seems i need some kind of do until loop perhaps?

        ddlFullTime.Items.Add(New System.Web.UI.WebControls.ListItem(dtMod.ToShortTimeString, dtMod.ToShortTimeString))
        dtMod = dtMod.AddMinutes(15)
        ddlFullTime.Items.Add(New System.Web.UI.WebControls.ListItem(dtMod.ToShortTimeString, dtMod.ToShortTimeString))
        dtMod = dtMod.AddMinutes(15)

Open in new window

0
Comment
Question by:Dale Massicotte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 39860704
Try this:
ddlFullTime.Items.Add(New System.Web.UI.WebControls.ListItem("Now", dtNow.ToShortTimeString))
dtMod =  DateTime.Now.AddMinutes(15 - (DateTime.Now.AddMinutes(15).Minute Mod 15))
Dim target As DateTime = Convert.ToDateTime("11:45 PM")
While (dtMod.TimeOfDay < target.TimeOfDay)
    dtMod = dtMod.AddMinutes(15)
    ddlFullTime.Items.Add(New ListItem(dtMod.ToShortTimeString, dtMod.ToShortTimeString))
    
End While

Open in new window

0
 

Author Comment

by:Dale Massicotte
ID: 39860719
Why reinvent the wheel when you have guru_sami?

My brain is too slow and my loop sucked

Thanks for the code to sort of parse the date and time out.

I was almost there!
0
 

Author Closing Comment

by:Dale Massicotte
ID: 39860720
A+++++++++++++++++
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 39860744
Thanks. Glad to help.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question