| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 507 人关注过本帖
标题:高手帮忙!关于逻辑判断的一段函数
只看楼主 加入收藏
king99121
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-1-31
收藏
 问题点数:0 回复次数:0 
高手帮忙!关于逻辑判断的一段函数
    Private Sub LoadFriendLink(iXMLDom)
        Dim SQL,Rs,i,Node,datalist
        Dim sAppID,rootNode,strQuery
        Dim channid,maxnum,stype,setcache
        Dim isLogo,linkmode,strLinks,strImage
        Dim Eachline,w,strwidth
        If IsNull(iXMLDom.documentElement.getAttribute("action")) Then iXMLDom.documentElement.setAttribute "action","0"
        If IsNull(iXMLDom.documentElement.getAttribute("select")) Then iXMLDom.documentElement.setAttribute "select","0"
        If IsNull(iXMLDom.documentElement.getAttribute("eachline")) Then iXMLDom.documentElement.setAttribute "eachline","0"
        If IsNull(iXMLDom.documentElement.getAttribute("islogo")) Then iXMLDom.documentElement.setAttribute "islogo",""
        If IsNull(iXMLDom.documentElement.getAttribute("linkmode")) Then iXMLDom.documentElement.setAttribute "linkmode",""
        If IsNull(iXMLDom.documentElement.getAttribute("target")) Then iXMLDom.documentElement.setAttribute "target","_blank"
        setcache    = NewAsp.CheckStr(iXMLDom.documentElement.getAttribute("setcache"))
        channid        = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("channelid"))
        maxnum        = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("maxnum"))
        stype        = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("type"))
        rootNode    = NewAsp.CheckStr(iXMLDom.documentElement.getAttribute("node"))
        isLogo        = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("islogo"))
        linkmode    = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("linkmode"))
        eachline    = NewAsp.ChkNumeric(iXMLDom.documentElement.getAttribute("eachline"))
        setLineWidth Eachline,strwidth,w
        
        If setcache="" Then setcache="0"
        If maxnum=0 Or maxnum>100 Then maxnum=10
        sAppID        = NewAsp.CacheName &"_friendlink_"&setcache
        If rootNode = "" Or rootNode = "row" Or rootNode = "xml" Then rootNode = "datalist"
        Select Case stype
            '-- 首页显示按时间升序排列
            Case 1: strQuery="And isIndex>0 ORDER BY LinkTime DESC,LinkID DESC"
            '-- 首页显示按点击数升序排列
            Case 2: strQuery="And isIndex>0 ORDER BY LinkHist DESC,LinkID DESC"
            '-- 首页显示按点击数降序排列
            Case 3: strQuery="And isIndex>0 ORDER BY LinkHist DESC,LinkID ASC"
            '-- 所有按升序排列
            Case 4: strQuery="ORDER BY LinkID DESC"
            '-- 所有按降序排列
            Case 5: strQuery="ORDER BY LinkID ASC"
            '-- 所有按点击数升序排列
            Case 6: strQuery="ORDER BY LinkHist DESC,LinkID DESC"
            '-- 所有按点击数降序排列
            Case 7: strQuery="ORDER BY LinkHist DESC,LinkID ASC"
            '-- 首页显示按名称排列
            Case 8: strQuery="And isIndex>0 ORDER BY LinkName DESC,LinkID DESC"
            '-- 所有按名称排列
            Case 9: strQuery="ORDER BY LinkName DESC,LinkID DESC"
            Case Else
                strQuery="And isIndex>0 ORDER BY LinkTime Asc,LinkID ASC"
        End Select
        If isLogo=0 Then
            SQL = "SELECT TOP "&maxnum&" LinkID,LinkName,LinkUrl,LogoUrl,Readme,LinkHist,isLogo FROM [NC_Link] WHERE isLock=0 And isLogo=0 " & strQuery
        Else
            SQL = "SELECT TOP "&maxnum&" LinkID,LinkName,LinkUrl,LogoUrl,Readme,LinkHist,isLogo FROM [NC_Link] WHERE isLock=0 And isLogo>0 " & strQuery
        End If
        If Not CacheIsObject(setcache,sAppID) Then
            Set Rs = NewAsp.Execute(SQL)
            Set datalist = NewAsp.RecordsetToxml(rs,"row",rootNode)
            Rs.Close:Set Rs = Nothing
            If EnabledCache(setcache) Then
                Application.Lock
                    Set Application(sAppID)=datalist
                Application.unLock
            End If
            If Not datalist Is Nothing Then
                i=0
                For Each Node In datalist.documentElement.SelectNodes("row")
                    i=i+1
                    Node.attributes.setNamedItem(datalist.createNode(2,"i","")).text = i
                    Node.attributes.setNamedItem(datalist.createNode(2,"w","")).text = w
                    Node.attributes.setNamedItem(datalist.createNode(2,"linewidth","")).text = strwidth
                    If Eachline=0 Then
                        If (i Mod Eachline)=0 Then
                            Node.attributes.setNamedItem(datalist.createNode(2,"br","")).text="<br style=""clear:both"" />"
                        Else
                            Node.attributes.setNamedItem(datalist.createNode(2,"br","")).text=""
                        End If
                    Else
                        Node.attributes.setNamedItem(datalist.createNode(2,"br","")).text=""
                    End If
                    If (i mod 2) > 0 Then
                        Node.attributes.setNamedItem(datalist.createNode(2,"m","")).text = 2
                    Else
                        Node.attributes.setNamedItem(datalist.createNode(2,"m","")).text = 1
                    End If
                    If linkmode>0 Then
                        strLinks=NewAsp.InstallDir&"link/link.asp?id="&Node.selectSingleNode("@linkid").text&"&url=" & Trim(Node.selectSingleNode("@linkurl").text)
                        If NewAsp.BindDomain=1 Then strLinks=NewAsp.MainDomain&strLinks
                    Else
                        strLinks=Trim(Node.selectSingleNode("@linkurl").text)
                    End If
                    If CLng(Node.selectSingleNode("@islogo").text)>0 Then
                        strImage=NewAsp.CheckLinksUrl(Node.selectSingleNode("@logourl").text)
                        Node.selectSingleNode("@logourl").text=strImage
                    End If
                    Node.attributes.setNamedItem(datalist.createNode(2,"link","")).text=strLinks
                    Node.attributes.setNamedItem(datalist.createNode(2,"title","")).text=Node.selectSingleNode("@linkname").text
                Next
                Set Node = Nothing
                If Eachline>1 Then
                    Dim moreline
                    If i<Eachline Then moreline=Eachline-i Else moreline=Eachline-(i Mod Eachline)
                    If moreline>0 And moreline<Eachline Then
                        strLinks=NewAsp.InstallDir&"link/"
                        If NewAsp.BindDomain=1 Then strLinks=NewAsp.MainDomain&strLinks
                        For i=i+1 To i+moreline
                            Set Node=datalist.createNode(1,"row","")
                            Node.attributes.setNamedItem(datalist.createNode(2,"i","")).text=i
                            Node.attributes.setNamedItem(datalist.createNode(2,"w","")).text = w
                            Node.attributes.setNamedItem(datalist.createNode(2,"linewidth","")).text = strwidth
                            If Eachline>0 Then
                                If (i Mod Eachline)=0 Then
                                    Node.attributes.setNamedItem(datalist.createNode(2,"br","")).text="<br style=""clear:both"" />"
                                Else
                                    Node.attributes.setNamedItem(datalist.createNode(2,"br","")).text=""
                                End If
                            Else
                                Node.attributes.setNamedItem(datalist.createNode(2,"br","")).text=""
                            End If
                            If (i mod 2) = 0 Then
                                Node.attributes.setNamedItem(datalist.createNode(2,"m","")).text = 2
                            Else
                                Node.attributes.setNamedItem(datalist.createNode(2,"m","")).text = 1
                            End If
                            Node.attributes.setNamedItem(datalist.createNode(2,"linkhist","")).text=0
                            Node.attributes.setNamedItem(datalist.createNode(2,"linkid","")).text=0
                            Node.attributes.setNamedItem(datalist.createNode(2,"islogo","")).text=isLogo
                            Node.attributes.setNamedItem(datalist.createNode(2,"logourl","")).text=strLinks&"link.gif"
                            Node.attributes.setNamedItem(datalist.createNode(2,"title","")).text="更多链接"
                            Node.attributes.setNamedItem(datalist.createNode(2,"linkname","")).text="更多链接"
                            Node.attributes.setNamedItem(datalist.createNode(2,"readme","")).text="更多链接"
                            Node.attributes.setNamedItem(datalist.createNode(2,"linkurl","")).text=strLinks
                            Node.attributes.setNamedItem(datalist.createNode(2,"link","")).text=strLinks
                            datalist.documentElement.appendChild(Node)
                            Set Node=Nothing
                        Next
                    End If
                End If
            End If
        Else
            Set datalist=Application(sAppID)
        End If
        If Not datalist Is Nothing Then iXMLDom.documentElement.appendChild(datalist.documentElement.cloneNode(True))
        Set datalist=Nothing
    End Sub



上面的这段是友情链接的显示方式的模板源码,判断islogo字段为0则显示为文字链接,islogo>0则为logo链接。现在我想修改为大于0的都用文字链接,小于0的则用文本链接。请问如何实现?因为我要用分类,为了整套程序的前台调用,不得不改,恳请高手赐教。
搜索更多相关主题的帖子: 判断 函数 逻辑 
2010-01-31 03:40
快速回复:高手帮忙!关于逻辑判断的一段函数
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048659 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved