asp中with End with

字號:


    在看高手寫的asp代碼中看到asp代碼用with來表示對象,其asp結(jié)構(gòu)形式 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關(guān)于with end with 內(nèi)容"
    .close
    else
    response.write "有相關(guān)asp中with end with的內(nèi)容"
    .close
    end if
    end with
    %>
    上面是關(guān)于with 的一個例子.查詢微軟官方網(wǎng)站制作學習網(wǎng)
    with ..end with 執(zhí)行重復引用單個對象或結(jié)構(gòu)的一系列語句。
    參考地址:http://msdn.microsoft.com/zh-cn/library/wc500chb(VS.80).aspx
    其實也很好理解with ..end with的意思
    就是在下面的語句中省略了with 后參數(shù).可以直接調(diào)用其.方法的形式
    再次舉例
    <%
    Class forasp'定義一個類
    Public webname
    Public weburl
    End class
    Set foraspcn = new forasp'設(shè)置foraspcn為一個對象
    with foraspcn
    .webname= "這里是網(wǎng)站制作學習網(wǎng)"
    .weburl = "http://www.ynpxrz.com/"
    end with
    response.write foraspcn.weburl
    %>