i am confused in a small concepts

梦想与她 提交于 2019-12-11 01:29:39

问题


I am very new to VBscript and learning hard all the concepts. During my practice I am stuck with a doubt.

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

When I execute this there is no error message and it works fine. But when I change

c = b.datecreated TO set c = b.datecreated than

it shows this error:

> object required:'datecreated'

I know it's a basic thing but some time small things make you learn a lot and helpful for future.


回答1:


The keyword Set is used in VBScript only for assignment of objects:

set a = CreateObject("scripting.filesystemobject")

Non-objects - like the creation date - are assigned without Set.

c = b.datecreated

(This is my favorite nastiness of VBScript.)



来源:https://stackoverflow.com/questions/15053319/i-am-confused-in-a-small-concepts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!