Skip to content

Instantly share code, notes, and snippets.

@honda0510
Last active December 9, 2015 17:49
Show Gist options
  • Save honda0510/4306310 to your computer and use it in GitHub Desktop.
Save honda0510/4306310 to your computer and use it in GitHub Desktop.
VBScript向けにFormat関数を作ってみた。でも、コマンドプロンプトが表示される。
Option Explicit
MsgBox Format(Date, "yyyyMMdd")
Function Format(DateTime, Pattern)
Dim command, wshShell, wshShellStatus, Stream
command = "PowerShell -Command Get-Date """ & DateTime & """ -Format """ & Pattern & """"
Set wshShell = CreateObject("WScript.Shell")
Set wshShellStatus = wshShell.Exec(command)
Set Stream = wshShellStatus.StdOut
wshShellStatus.Terminate
Format = Stream.ReadAll
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment