我对 VBscript 非常陌生,正在努力学习所有概念。在我的实践过程中,我一直有一个疑问。
dim a,b,c
set a = CreateObject("scripting.filesystemobject") 'initiate the file system object'
set b = a.GetFolder("E:\test") 'returns a object . and for the instance that varaiable b refers to that returned object'
c = b.datecreated 'accesing and storing the property to a variable /C/'
msgbox "folder: " &c
当我执行此操作时,没有错误消息并且工作正常。但当我改变时
c = b.datecreated
TO 设置 c = b.datecreated
大于
它显示此错误:
> object required:'datecreated'
我知道这是一件基本的事情,但有时小事情会让你学到很多东西,对 future 很有帮助。
最佳答案
关键字Set
在VBScript中仅用于对象的赋值:
set a = CreateObject("scripting.filesystemobject")
非对象(例如创建日期)在没有 Set
的情况下进行分配。
c = b.datecreated
(这是我最喜欢的 VBScript 的肮脏之处。)
关于vbscript - 我对一些小概念感到困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15053319/