Results 1 to 2 of 2

Thread: Problems with date

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Posts
    98

    Question 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

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    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

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width