一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

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

时间:2008-01-12 编辑:简简单单 来源:一聚教程网

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

热门栏目