Results 1 to 4 of 4

Thread: Date/Time/String manipulation [RESOLVED]

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Resolved Date/Time/String manipulation [RESOLVED]

    Sorry if I've missed it, but I had a quick search for similar problems and didn't turn anything up.

    I have a GUI with two text fields where the user enters a date into one and the time into another. I then need to concatenate the two strings together into a date variable.

    VB Code:
    1. Dim datFromDate As Date
    2.  
    3. datFromDate = CDate(txtFromDate.Text) & CDate(txtFromTime.Text)

    Any ideas, because this just throws up a Type Mismatch error.
    Last edited by Hack; May 2nd, 2006 at 07:21 AM. Reason: Added green "resolved" checkmark

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Date/Time/String manipulation

    Two date cannot be concatenated, so you should first concatenate the strings and then convert the resulting string into the date.
    VB Code:
    1. Dim datFromDate As Date
    2.  
    3. datFromDate = CDate(txtFromDate.Text & " " & txtFromTime.Text)
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Date/Time/String manipulation

    Quote Originally Posted by Moik
    Sorry if I've missed it, but I had a quick search for similar problems and didn't turn anything up.

    I have a GUI with two text fields where the user enters a date into one and the time into another. I then need to concatenate the two strings together into a date variable.

    VB Code:
    1. Dim datFromDate As Date
    2.  
    3. datFromDate = CDate(txtFromDate.Text) & CDate(txtFromTime.Text)

    Any ideas, because this just throws up a Type Mismatch error.
    Maybe:
    VB Code:
    1. t = CDate(txtFromDate.Text & " " & txtFromTime.Text)
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: Date/Time/String manipulation

    Yep. That does it. I'll mark as resolved.

    Thanks everyone.

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