在看高手写的asp代码中看到asp代码用with来表示对象,其asp结构形式 with ...End with.
代码如下:
<% sql = "select * from table" set rs = server.createObject("adodb.recordset") with rs .open sql,foraspcn,1,1 if .eof or .bof then response.write "没有asp关于with end with 内容" .close else response.write "有相关asp中with end with的内容" .close end if end with %>
上面是关于with 的一个例子.查询微软官方网站制作学习网
with ..end with 执行重复引用单个对象或结构的一系列语句。
参考地址:http://msdn.microsoft.com/zh-cn/library/wc500chb(VS.80).aspx
其实也很好理解with ..end with的意思
就是在下面的语句中省略了with 后参数.可以直接调用其.方法的形式
再次举例
<% Class forasp'定义一个类 Public webname Public weburl End class Set foraspcn = new forasp'设置foraspcn为一个对象 with foraspcn .webname= "这里是网站制作学习网" .weburl = "http://www.ynpxrz.com/" end with response.write foraspcn.weburl %>