我在一个小概念中感到困惑

时间:2013-02-24 15:35:57

标签: vbscript qtp

我是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.datecreatedset c = b.datecreated而不是

它显示此错误:

> object required:'datecreated'

我知道这是一件基本的事情,但是有些时候小事会让你学到很多东西,对未来有所帮助。

1 个答案:

答案 0 :(得分:5)

VBScript中仅使用关键字Set来分配对象:

set a = CreateObject("scripting.filesystemobject")

非对象(如创建日期)未分配Set

c = b.datecreated

(这是我最喜欢的VBScript肮脏。)