I try to get the minute difference in TextBox
with two controls DateTimePicker .
When compiling the program for the first time it shows me a very long number, then when changing the time in the control, it does show me the time.
This code is being executed in the event ValueChanged
of each DateTimePicker . That is, it is found as such in each of the 2 events, but it is strange because it only happens when I execute it initially.
DateTime horaInicio = dtpHorainicial.Value;
DateTime horaFinal = dtpHorafinal.Value;
// A la hora final le restamos la hora de inicio
TimeSpan diferencia = horaFinal.Subtract(horaInicio);
// Mostramos la diferencia en un control TextBox
txt_tiempoTotal.Text = $"{diferencia.TotalMinutes} Minutos";