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:
When I ran the code, I got both values are equal (dtStartDate value = dtEndDate).
if (dtStartDate.Value > dtEndDate.Value)
DateTimePicker dtTemp = new DateTimePicker();
dtTemp.Value = dtStartDate.Value;
dtStartDate.Value = dtEndDate.Value;
dtEndDate.Value = dtTemp.Value;
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.
You can use dtStartDate_CloseUp;
after performance dtStartDate.Value = dtEndDate.Value;
another dtStartDate_ValueChanged occurs
By Luis Afonso in forum Database
Last Post: 04-11-2001, 05:20 AM
By IvyS in forum Database
Last Post: 02-14-2001, 03:16 PM
By tyris in forum VB Classic
Last Post: 02-01-2001, 02:08 AM
By tyris in forum Database
Last Post: 01-24-2001, 01:45 PM
By Andreas Roth in forum VB Classic
Last Post: 04-10-2000, 09:43 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center