Problem in swap DateTimePicker values


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Problem in swap DateTimePicker values

  1. #1
    Join Date
    Dec 2003
    Posts
    11

    Problem in swap DateTimePicker values

    Hi, I have two DateTimePickers to determine date range, with their names are dtStartDate and dtEndDate.
    I want to swap their values if dtStartDate value > dtEndDate.
    In dtStartDate_ValueChanged event, I only write codes as follows:
    Code:
    if (dtStartDate.Value > dtEndDate.Value)
    {
         DateTimePicker dtTemp = new DateTimePicker();
         dtTemp.Value = dtStartDate.Value;
         dtStartDate.Value = dtEndDate.Value;
         dtEndDate.Value = dtTemp.Value;
    }
    When I ran the code, I got both values are equal (dtStartDate value = dtEndDate).
    Step by step debugging showed their values were swapped.
    But when the debug step exit from dtStartDate_ValueChanged event, both values became equal.
    I guess it happened because of the value passed as reference, not as value.
    How to fix it, so I can swap both values?
    Thanks for your help / direction.

  2. #2
    Join Date
    Sep 2006
    Posts
    2
    You can use dtStartDate_CloseUp;

    after performance dtStartDate.Value = dtEndDate.Value;
    another dtStartDate_ValueChanged occurs

Similar Threads

  1. INSERT INTO. prb: non-integer values.
    By Luis Afonso in forum Database
    Replies: 2
    Last Post: 04-11-2001, 05:20 AM
  2. Efficiency problem
    By IvyS in forum Database
    Replies: 0
    Last Post: 02-14-2001, 03:16 PM
  3. quote in a string : query problem under VB
    By tyris in forum VB Classic
    Replies: 6
    Last Post: 02-01-2001, 02:08 AM
  4. quote in a string : query problem
    By tyris in forum Database
    Replies: 2
    Last Post: 01-24-2001, 01:45 PM
  5. Major Problem with RDO 2.0, ODBC 3.5, SQL Server7
    By Andreas Roth in forum VB Classic
    Replies: 0
    Last Post: 04-10-2000, 09:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center