簡體   English   中英

如何使用VBScript打開記事本並粘貼DDMMYYYY格式的當前日期?

[英]How to use VBScript to open notepad and paste current date with DDMMYYYY format in it?

如何使用 VBScript 打開記事本並以 DDMMYYYY 格式粘貼當前日期?

當我使用下面的代碼時,我得到 DD/MM/YYYY 格式的輸出。 我想要 DDMMYYYY 格式。

set WshShell = WScript.CreateObject("WScript.Shell")

call WshShell.Run("%windir%\system32\notepad.exe")

Dim aDate

aDate = Date()

WScript.Sleep 4000

WshShell.SendKeys aDate

你們能幫我解決這個問題嗎?

你想要的日期格式: DDMMYYYY(沒有常見的斜線)

這應該適合你:

Dim WshShell: Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run("%windir%\system32\notepad.exe")
WScript.Sleep 4000

Dim aDate: aDate = WScript.CreateObject("System.Text.StringBuilder").AppendFormat("{0:dd}{0:MM}{0:yyyy}", Now).ToString()

WshShell.SendKeys aDate

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM