频道直达 - 学院 - 下载 - 交易 - 特效 - 字库 - 手册 -排名-工具- 繁體
网页教学网站开发 设为首页
加入收藏
联系我们
建站搜索: 常用广告代码   用户注册 | 用户登陆
您当前的位置:中国建站之家 -> 网站开发设计技术教程 -> asp教程 -> 在VB组件中使用串缓冲 - 1

在VB组件中使用串缓冲 - 1

作者:未知  来源:转载  发布时间:2005-9-19 8:42:59  发布人:acx

减小字体 增大字体

Lesson 1 : Overview
--------------------------------------------------------------------------------

This article serves as a quick "How To" example for using string buffering to concatenate strings in a VB
component. The example VB code will generate a HTML TABLE record that will be sent to an asp file after
being populated with data from a database table. The GetRows() method will be used to acquire the data
from an example Access database.

In many circumstances, sending a Variant array populated by GetRows(), (or a RecordSet) to an asp file
from a VB component is the recommended way to build a HTML TABLE record. Other times you may choose to
build a HTML TABLE record, or other database dependant code, within the VB component itself before sending
it to an asp file. This may not set well with the "true believers" in not mixing HTML and VB code. I tend
to be agnostic and I find sacrificing orthodoxy for speed is sometimes called for with server-side
components. In any regard, this programming choice is exemplified here.

Rather than sending the HTML code from the VB component with the Response.Write method, you can optionally
collect the HTML within a string and send it back as a complete HTML TABLE record. This avoids the need to
instantiate the asp object within the VB component. It also allows other VB code to use your component
without reference to asp. You"re just generating pure HTML code that any COM object can use. But when
putting together a large HTML string in VB, the concatenation operant "&" can slow your code down
significantly.

We"ll be creating two methods, MethodName() and DoBuffer(). The MethodName() method will acquire data from
a database and then use this data to construct a HTML TABLE record it will send to the calling asp file in
one lump sum. Our asp file will initially call the MethodName() method with an sql statement, a connection
string, and the number of fields used in our sql statement. In order to generate the HTML string with the
least use of the concatenation operant, the MethodName() method will send the string fragments it uses to
build the HTML TABLE record to the DoBuffer() method.

The supporting database file, text, and code, for this article can be downloaded here. If you"re
unfamiliar with writing a server-side VB dll, you can read some introductory articles at my site. This
example will include a VB server-side dll (ActiveX dll) consisting of one class (ClassName) and two
methods (MethodName and DoBuffer). The VB project is named How2Project4.

For How2 articles on sending data to asp files with Variant Array/GetRows() and RecordSets see:
How To Pass a Variant Array Populated with a RecordSet From a VB Component to an asp File
How To Pass a RecordSet From a VB Component to an asp File.

NOTE:
The connection string value will need to contain the Data Source Name (DSN) that should first be
established with ODBC, although any valid database connection string will work here. ADO will also need to
be referenced in the VB project (see an introductory VB component article on how to do this).

Why Use String Buffering?
If you concatenate strings using the "&" operant, and you repeat this operation multiple times, processing
time will be significantly delayed compared to using string buffering. Here"s example code of both
techniques:

Concatenating using the "&" operant:


StrHold = "Testing one, "
StrHold = StrHold & "two, "
StrHold = StrHold & "three."


Concatenating using a string buffering method:


S1, S2, S3, "Testing one, "
S1, S2, S3, "two, "
S1, S2, S3, "three."


[This code fragment uses different method and variable names from the code in this article]

With large amounts of concatenating, I have experienced increases in speed of up to 1000 times greater
when using string buffering. This is primarily due to how VB manages the memory for strings with the "&"
operant.


将本文收藏到QQ书签与更多好友分享
[打 印]
[] [返回上一页] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
精彩推荐
热门文章
· 注册码大全二
· 注册码大全四
· 注册码大全一
· 要10G免费网络硬盘的请进..
· 通过google 赶快来赚美金..
· 注册码大全十
· 头像-qq头像(qq新头像)4..
· 让你轻松架设FTP服务器1..
· 注册码大全三
· 梦幻背景图片7
· 卡通动物图片6
· 网页制作素材-按钮素材2..
· 让你轻松架设FTP服务器5..
· 风景图片8
· 注册码大全九
· 让你轻松架设FTP服务器2..
关注此文读者还看过
· 用 Photoshop 做残旧的凶..
· 在Eclipse3.2上部署JSP全..
· 通过作业调度建立SQL Se..
· 在ASP中用EasyMailObjec..
· 一个防止外部数据提交的..
· Fireworks网页设计综合实..
· 一种细腻的导航效果的制..
· Flash视觉效果之漫天飞雪..
· VPN技术详解(上)
· 保存美丽记忆 用ASP.NET..
· 制作简单实用的FLASH导航..
· 在ASP中使用SQL语句之1:..
· 网页设计中利用JS控制网..
· (PHP)模板引擎Smarty介绍..
· 十二星座卡通图片
· asp.net高级教程(三)-..
相关文章
· 在VB组件中使用串缓冲 - 2
· 在VB组件中使用串缓冲 - 3
· 何让你的ASP运行于非Window..
· 制作我们自己的Ebay(拍卖系..
· 用XML数据岛解决用户界面问..
· 实现聊天室在线人员无刷新所..
· IMail基础教程(一) DNS设置..
· RFC821-简单邮件传输协议(..
· 用ASP+XML打造留言本 - 1
· 将HTML表单数据存储为XML格..
· 用表单来提交sql - 1
· 微软的远程处理框架.NET Re..
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 人才招聘
网站合作、内容监督、商务咨询:QQ: 9576619
Copyright ? 2005--2008 中国建站之家版权所有
粤ICP备05092265号