how to concatenate strings for Date in VB

Posted on 2009-02-16
Last Modified: 2013-11-25
Looking to have the below but don't know the exact way to put it. where month and year are retrived from txtbox.

startDate = "01/"&month&"/"&year
Question by:j8547
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    what version of vb?

    what is "startdate"?
    LVL 67

    Expert Comment

    startDate = "01/" & Month(Date) & "/" & Year(Date)
    LVL 67

    Accepted Solution

    oops - from a textbox...
    strDate = "01/" & txtBox1.Text & "/" & txtBox2.Text
    LVL 2

    Expert Comment

    I assume you are talking about Visual Basic 6.0.

    Its straight forward like,-

    Dim d1 As Date

    d1 = CDate("01" & "/" & txtMonth.Text & "/" & txtYear.Text )

    Where txtMonth and txtYear are the assumed names of the textboxes.

    Hope it helps!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now