Jump to content

[Resolvido] Erro no datetimepicker


Recommended Posts

Boas, tenho este panel...


Eu quero tipo deixar a data de hoje como a data predefinida mas ao mudar a data da data entrada, quando escrevo na textbox numero de noites aparece o datetimepicker da data de saida, eis o erro:


Dia 9 + 10 seria dia 19 ...

Eis a minha programação:

Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
	Data_EntradaDateTimePicker.MinDate = Today
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
	If dias_Reserva.Text = "" Then
		Data_SaídaDateTimePicker.Visible = True
		Data_SaídaDateTimePicker.Value = DateTime.Now.AddDays(Integer.Parse(dias_Reserva.Text))
		' Data_SaídaDateTimePicker.Value = Data_EntradaDateTimePicker.Value = (Integer.Parse(dias_Reserva.Text))
		PrecoLabel1.Text = dias_Reserva.Text * Preco_Tipo_QuartoLabel1.Text
	End If
End Sub

Acho que o meu erro está nesta linha devido ao "Now" :

  Data_SaídaDateTimePicker.Value = DateTime.Now.AddDays(Integer.Parse(dias_Reserva.Text))
Edited by ribeiro55
Link to comment
Share on other sites

Terás de aplicar a soma à data de entrada, e não à data actual.


Data_SaídaDateTimePicker.Value = Data_EntradaDateTimePicker.Value.AddDays(NumericUpDown1.Value)

Sérgio Ribeiro

"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.