Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

visual studio dropdownlist calculate time values

Posted on 2014-02-14
4
Medium Priority
?
229 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

649 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