2013-02-24 67 views
2

我对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 set c = b.datecreated

它显示了这个错误:

> object required:'datecreated' 

我知道这是一个基本的东西,但一段时间后小东西让你学习为未来的很多,乐于助人。

回答

5

关键字Set在VBScript仅用于对象的分配:

set a = CreateObject("scripting.filesystemobject") 

非对象 - 如创建日期 - 没有Set分配。

c = b.datecreated 

(这是我最喜欢的VBScript的污秽。)

+1

...有相当选择从列表! – 2013-02-24 15:47:42

+0

对我来说,问题不在于不一致,而在于缺乏文档 - 用户只能通过口耳相传来了解这些小怪癖。 – entonio 2013-02-24 16:13:34

+0

@ entonio ....我会保持这个在我心中...感谢您的指导 – pushkar7767 2013-02-25 08:17:51