Advertisement

07.29.2005 at 06:34AM PDT, ID: 21508991
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Two Calendars in a form?

Asked by trwagner1 in .NET

Tags:

I'm working on a project that queries a SQL database.  My current phase deals with selecing dates from a calendar and passing those dates to a report page which used the two dates from the previous page in a sql string.  They pick two dates and click submit to pass the querystrings to a second page where the datagrid is located.

I'm using VB in asp.net.  To make date selection easier, I'm trying to use two calendars.  Calendar1 is used to select the report "start" date.  Calendar2 is used to select the report "end" date.  The dates can be as far apart as the user desires including the start and end date selections being the same day.  The only restrictions I am trying to limit is a) the user cannot pick a date in the future, b) the user cannot pick a start date which is greater than the end date, c) likewise, the user can't choose an end date first which is less than the start date.

For instance, if I want to report on the period between Tuesday, July 5th 2005 and Thursday, July 14th 2005, I select those respective dates accordingly.

I've tried so many different things I don't know where to start.  But, here's what it boils down to.  I always set the selecteddate property to date.now.  At all times, I need to compare dates.  However, there are conditions when Calendar1 ignores Calendar2 and vice versa.  I'm trying to prevent the user from picking illogical dates.  Currently, my page works if the user picks the start date and end date correctly right off the bat.  However, I've had cases where they change their mind after picking a start date and end date and then they go BACK to calendar1 and change the date without clicking the clear button to reset the calendars.

I'm quite positive it's my error logic that I'm using.  I've tried checking/comparing date values within each calendar change function.  

I've tried searching the internet for examples of this situation.  

My example code here is going to be quite a mess as I've been making multiple changes and it's VERY buggy at the moment, but you'll get the idea.

       Sub Selection_Change1(ByVal sender As Object, ByVal e As EventArgs)
           If Calendar1.SelectedDate.ToShortDateString < Calendar2.SelectedDate.ToShortDateString Then
               Label1.ForeColor = Drawing.Color.Black
               Label1.Text = Calendar1.SelectedDate.ToShortDateString
               Label2.Text = Calendar2.SelectedDate.ToShortDateString
           ElseIf Calendar1.SelectedDate.ToShortDateString > Calendar2.SelectedDate.ToShortDateString Then
               Label1.ForeColor = Drawing.Color.Red
               Label1.Text = "Start date is greater than end date. Please try again. Calendar1 " & Calendar1.SelectedDate.ToShortDateString
               Label2.Text = Calendar2.SelectedDate.ToShortDateString
           End If
       End Sub 'Selection_Change for Calendar1
           
       
       Sub Selection_Change2(ByVal sender As Object, ByVal e As EventArgs)
           If Calendar2.SelectedDate.ToShortDateString > Calendar1.SelectedDate.ToShortDateString Then
               Label2.ForeColor = Drawing.Color.Black
               Label2.Text = Calendar2.SelectedDate
           ElseIf Calendar2.SelectedDate.ToShortDateString < Calendar1.SelectedDate.ToShortDateString Then
               Label2.ForeColor = Drawing.Color.Red
               Label2.Text = "End date is less than start date.  Please try again. Calendar2 " & Calendar2.SelectedDate.ToShortTimeString
           End If
       End Sub 'Selection_Change for Calendar2

So, my question is, how do I accomplish what I want to do?  I'm still a greenhorn when it comes to a lot of vb programming, so please go easy on this old man.

Thanks

TedStart Free Trial
 
Loading Advertisement...
 
[+][-]07.29.2005 at 06:37AM PDT, ID: 14554448

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.29.2005 at 10:26AM PDT, ID: 14556808

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.29.2005 at 11:59AM PDT, ID: 14557724

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.29.2005 at 12:16PM PDT, ID: 14557872

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: .NET
Tags: sql
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.29.2005 at 12:19PM PDT, ID: 14557891

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.29.2005 at 12:22PM PDT, ID: 14557907

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32