-
Problems with date
When my page displays the text box contains a string date format. ex: 0/0/1
I want it to display the date that is displayed on the dtpicker control..
I tried this DateBox.value = dtpicker1.value
Actually here is my code:
Sub Window_Onload
on error resume next
Form1.DateBox.value = empty
window.settimeout "Init", 5, vbscript
Form1.DateBox.value = cstr(form1.Dtpicker1.month) & "/" & cstr(form1.dtpicker1.day) & "/" & cstr(form1.dtpicker1.year)
end sub
sub Init
form1.dtpicker1.value = now
end sub
-
Code:
Option Explicit
Private Sub Form_Load()
Text1.Text = Date
End Sub
Private Sub DTPicker1_Change()
Text1.Text = DTPicker1.Value
End Sub
It looks as though you want the text box to display this figure when the form loads. Well... the datepicker control's initial date when it first loads is set to todays date, so rather than worrying about this datepicker control altogether, you can use the date() function to grab todays date. ;)
If you want the text box to update when the user chooses a new date from the datepicker control, you can use the second sub above (using the change event of the control). :)
Anything which is displayed inside of a textlbox is automatically a string value anyway - so no need to worry with the CStr() function.
Cheers :cool: