With...End With
该语句可以用来简化代码,With之后紧跟一个对象,在With和End
With之间,可以用圆点符号“.”代替“变量.”。
例如:
Dim
StartDate
As
Date =
Date.Today
With StartDate
Output.Show("年:"
& .Year)
Output.Show("月:"
& .Month)
Output.Show("日:"
& .Day)
End
With
上面的代码等效于:
Dim
StartDate
As
Date =
Date.Today
Output.Show("年:" &
StartDate.Year)
Output.Show("月:" &
StartDate.Month)
Output.Show("日:"
& StartDate.Day)
Year、Month、Day都是日期型数据的属性,后面的章节我们会介绍。
本页地址:http://www.foxtable.com/webhelp/topics/0346.htm