论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > asp教程
Tag:入门,文摘,实例,技巧,iis,表单,对象,上传,数据库,记录集,session,cookies,存储过程,注入,分页,安全,优化,xmlhttp,fso,jmail,application,防盗链,stream,组件,md5,乱码,缓存,加密,验证码,算法,ubb,正则表达式,水印,,日志,压缩,url重写,控件,函数,破解,触发器,socket,ADO,初学,聊天室,留言本,视频教程

不用组件来实现StrCat函数的功能

文章类别:asp | 发表日期:2008-10-5 20:53:32

really really slow by nature. This sample code uses classes to speed up the process by ten times. Someone recentally came up with a DLL to do this but not all of us can install a DLL on our ISP's web servers so I wrote this easy to use VB Class for handling string concatenation.

code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!


Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.  


    '**************************************
    ' Name: StrCat - Non DLL version
    ' Description:ASP's ability to concatena
    '     ting many strings together is really rea
    '     lly slow by nature. This sample code use
    '     s classes to speed up the process by ten
    '     times. Someone recentally came up with a
    '     DLL to do this but not all of us can ins
    '     tall a DLL on our ISP's web servers so I
    '     wrote this easy to use VB Class for hand
    '     ling string concatenation.
    ' By: Kevin Pirkl
    '
    ' Inputs:Public Property Length - To res
    '     ize the string length. To use it a secon
    '     d time on another string just set the .L
    '     ength property to another value or just
    '     dereference the object and recreate it.
    Public Method Add - too add data to the concatenated string.
    '
    ' Assumes:Didnt do much testing except u
    '     sing it to add together a string of 100,
    '     000 characters and it took about 7 secon
    '     ds which is not bad. If you need to add
    '     together more than that dont use this. I
    '     f your catting char strings like "<TR
    '     >" + whatever then it should be ok.
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/xq/ASP/txtCode
    '     Id.6342/lngWId.4/qx/vb/scripts/ShowCode.
    '     htm    'for details.    '**************************************
    
    Set X = New strCat' Create an instance of strCat
    X.Length = 100001' Change from the default String length of 100,000
    str = ""
    For I = 1 To X.Length
     X.Add("A") '- takes 7 seconds on my computer
     'str = str & "A"'- takes 1 minute 7 seconds on my computer
    Next
    msgBox(Len(X.Value))
    X.Length = 101
    For I = 1 To X.Length
     X.Add("B")
    Next
    msgBox(Len(X.Value))
    Set X = Nothing ' Destroy the instance.
    msgBox("Done")
    Class strCat
     Private IntCntr
     Private strArray()
     Private intLength
     Public Property Get Length
     Length = intLength
     End Property
     Public Property Let Length( ByVal intLen)
     intLength = intLen
     IntCntr = 0
     Redim strArray(1)
     strArray(0) = ""
     Redim strArray(intLength)
     End Property
     Public Property Get Value
     Value = Join( strArray,"")
     End Property
     Private Sub Class_Initialize()
     IntCntr = 0
     Length = 100000
     End Sub
     Public Function Add( strToAdd)
     strArray(IntCntr) = strToAdd
     IntCntr= IntCntr + 1
     End Function
    End Class

上一篇:{技巧}不用java的垂直滚动看板 人气:3904
下一篇:{技巧}如何把ASP编写成DLL  人气:4319
视频教程列表
文章教程搜索
 
Asp推荐教程
Asp热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058