vbs对象成员的使用

Class CompExProp
	Private mComponent
	Private mShapeSize
	
	Private Sub Class_Initialize()
		mShapeSize=0
	End Sub
	'---------------begin set--------
	Public Property Let Component(ByVal objVar)
		mComponent=objVar
	End Property
	Public Property Let ShapeSize(ByVal objVar)
		mShapeSize=objVar
	End Property
	'--------end set---------
	'-----------begin get----------
	Public Property Get Component()
		Set Component=mComponent
	End Property
	Public Property Get ShapeSize()
		Set ShapeSize=mShapeSize
	End Property
	'--------end get-------
	
	
	Public Function clone(byval pCompExProp)
		Set Component=pCompExProp.Component
		Set ShapeSize=pCompExProp.ShapeSize
	End Function
	
End Class


	For i=1 To coll.count
		Dim objCompExProp
		Set objCompExProp=New CompExProp
		Set objCompExProp.Component=coll.item(i)	'error, object doesn't support this property or method:objCompExProp.Component. remove the "set" resolved it
		Set objCompExProp.ShapeSize=getShapeSize(coll.item(i))
		Call DictAdd(dict,"abc"&(i),objCompExProp)
		'Call output("  add into dict: abc"&(i)&" area: "&calcArea(coll.item(i)))	
	Next

一、时间与日期函数 01:Date函数 例子:Msgbox date 将会显示“2009-03-13” 02:time函数 例子 :Msgbox time 将显示“15:21:38” 03:now函数 例子Msgbox now 将显示“2009-03-13 15:23:13” 04:year(),month(),day(),hour(),minute(),second()函数,参数是时间表达式, 例子:Msgbox year(now) 将显示 2009 注意:当月份是个位数时不补零。 05:函数weekday( day,[first day of week])默认vbsunday =============对象部分==================== 一、FileSystemObject 对象-对应的方法 综述:Dim fso, MyFile Set fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.CreateTextFile("c:\testfile.txt", True) MyFile.WriteLine("This is a test.") MyFile.Close CreateObject 函数返回 FileSystemObject 对象 (fso)。CreateTextFile 方法创建一个文件作为 TextStream 对象 (a),然后 WriteLine 方法在此文件中写入一行文本。最后 Close 方法刷新缓冲区并关闭文件。 1:BuildPath 方法 向现有路径后添加名称。 object.BuildPath(path, name) object必选项。应为 FileSystemObject 对象的名称。 path必选项。要附加 name 的现有路径。可以是绝对或相对路径且无需指定现有文件夹。 name必选项。要附加到现有 path 的名称。 例子:Dim fso, newpath Set fso = CreateObject("Scripting.FileSystemObject") path="c:\program files" newpath = fso.BuildPath(path, "microsoft") GetBuildPath = newpath msgbox GetBuildPath 将会显示c:\program files\microsoft 2:CopyFile 方法 将一个或多个文件从某位置复制到另一位置。 object.CopyFile "source", "destination"[, overwrite] object必选项。应为 FileSystemObject 对象的名称。 source必选项。表示指定文件的字符串。要复制一个或多个文件时,文件名中可以有通配符。 destination必选项。表示目标位置的字符串,从 source 复制文件到该位置。不允许用通配符。 overwrite可选项。Boolean 值表明是否覆盖现有文件。如果是 True,则覆盖文件;如果是 False,则不覆盖现有文件。默认值是 True。要注意,无论 overwrite 设置为何值,只要设置 destination 为只读属性,CopyFile 操作就无法完成。 例子:Dim fso, newpath Set fso = CreateObject("Scripting.FileSystemObject") fso.copyfile "c:\test.txt","d:\a.txt" 将会复制那个文本文档到d盘,并且会改名称,如果指定目标为"d:\"就会不改名称。 3:CopyFolder 方法 将文件夹从某位置递归复制到另一位置。 object.CopyFolder source, destination[, overwrite] object必选项。应为 FileSystemObject 对象的名称。 source必选项。表示指定文件夹的字符串。要复制一个或多个文件夹时,可使用通配符。 destination必选项。表示目标位置的字符串,复制 source 文件夹或子文件夹到该位置。不允许用通配符。 overwrite可选项。Boolean 值表明是否覆盖现有文件夹。如果为 True,则覆盖文件;如果为 False,则不覆盖文件。默认值是 True。 例子:Dim fso, newpath Set fso = CreateObject("Scripting.FileSystemObject") fso.copyfolder "c:\test","d:\" ……………………………………………………………… …………………………………………………………
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值