Technology Software

How to Convert a String to a Date in VBA

    • 1). Open the Microsoft Office application for which you're writing your script, and press "Alt" and "F11" at the same time to open the VBA editor. Select the VBA script you want to edit by left clicking it on the left navigation pane, which will open the code window to the right. The default script is open already, so if you want to edit that, you don't need to click anything in the navigation pane. Locate the function in the file you just opened that you want to convert a date, and place your cursor there.

    • 2). Copy and paste the following code into your VBA function to define the string to be converted, substituting the desired date:
      Dim strDate = "August 13th, 2010"

    • 3). Copy and paste the following code under the previous code, to initialize the date variable and convert the string:
      Dim myDate
      myDate = CDate(strDate)
      MsgBox myDate

    • 4). Press "F5" to run your VBA code and see a message box appear with your converted date in it.

Related posts "Technology : Software"

How to Capture Analog Audio on My Computer

Software

Effective Photoshop Training Course to Enhance Your Photos

Software

How To Use Softphone Software For Your Business

Software

How to Access a String Array in JSP

Software

How Do I Get a Reversible Reaction Arrow in Microsoft Word 2007?

Software

How to Get AVCHD (MTS) Files to My PC

Software

Beat Detective Region Conform Tips

Software

MS BKF Repair Tool to Fix Corruption Owing to FAT File System

Software

Making an ASM Comparison

Software

Leave a Comment