最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在VB组件中使用串缓冲 - 2
时间:2022-06-30 11:12:18 编辑:袖梨 来源:一聚教程网
Lesson 2 : The VB Component
--------------------------------------------------------------------------------
How2Project4.vbp
The DoBuffer() Method
The DoBuffer() method will be sent a string buffer (strBuffer), the value of the length of the string data
already placed within the buffer (lngBuffer), and the string to add to the buffer (AddString). These
arguments will be declared and sent from our MethodName() method, which will be covered later in this
article.
Private Sub DoBuffer(ByRef strBuffer As String, ByRef lngBuffer As Long, ByVal AddString As String)
Notice that the DoBuffer() method is declared as a subroutine rather than a function. This is because it
doesn"t really return any data from the method itself. Rather, it manipulates the data sent by reference
from the calling method.
Two local variables need to be declared for internal use.
Dim strHold As String
Dim lngIndex As Long
Now our first line of business will be to determine whether our buffer is large enough to hold the string
data we want to add to it. But before we do this, we want to check out whether our calling method sent a
NULL string or not.
If Not Trim$(AddString) = "" Then
If the calling method sends a NULL string, we"ll quietly skip the concatenating process and avoid the
whole affair via this If-Then statement. On the other hand, if the sent string holds characters, we"ll
need to check that the buffer is large enough to hold them. To do this the current length of the data in
the buffer is added to the length of the sent string and then the resulting sum is compared to the length
of the overall buffer size.
If lngBuffer + Len(AddString) > Len(strBuffer) Then
If the buffer is large enough to fit the sent string, then the code discussed next will be skipped. This
will occur more often than not since we"ll set our string buffer to hold a large amount of data when we
--------------------------------------------------------------------------------
How2Project4.vbp
The DoBuffer() Method
The DoBuffer() method will be sent a string buffer (strBuffer), the value of the length of the string data
already placed within the buffer (lngBuffer), and the string to add to the buffer (AddString). These
arguments will be declared and sent from our MethodName() method, which will be covered later in this
article.
Private Sub DoBuffer(ByRef strBuffer As String, ByRef lngBuffer As Long, ByVal AddString As String)
Notice that the DoBuffer() method is declared as a subroutine rather than a function. This is because it
doesn"t really return any data from the method itself. Rather, it manipulates the data sent by reference
from the calling method.
Two local variables need to be declared for internal use.
Dim strHold As String
Dim lngIndex As Long
Now our first line of business will be to determine whether our buffer is large enough to hold the string
data we want to add to it. But before we do this, we want to check out whether our calling method sent a
NULL string or not.
If Not Trim$(AddString) = "" Then
If the calling method sends a NULL string, we"ll quietly skip the concatenating process and avoid the
whole affair via this If-Then statement. On the other hand, if the sent string holds characters, we"ll
need to check that the buffer is large enough to hold them. To do this the current length of the data in
the buffer is added to the length of the sent string and then the resulting sum is compared to the length
of the overall buffer size.
If lngBuffer + Len(AddString) > Len(strBuffer) Then
If the buffer is large enough to fit the sent string, then the code discussed next will be skipped. This
will occur more often than not since we"ll set our string buffer to hold a large amount of data when we
相关文章
- 无期迷途主线前瞻直播总结 无期迷途主线前瞻直播内容介绍 11-22
- 以下哪种非遗技艺是用针在纸上绣画 蚂蚁新村11月21日答案 11-22
- 江南百景图听风塔怎么样 11-22
- 原神恰斯卡圣遗物怎么搭配 11-22
- 2024年霸王茶姬11月22日口令是什么 2024.11.22霸王茶姬口令介绍 11-22
- 光遇11.21季节蜡烛在哪里 光遇11月21日季节蜡烛位置攻略 11-22