Using a string buffer in a VB component-2

Source: Internet
Author: User
Lesson 2:the VB Component
--------------------------------------------------------------------------------
How2project4.vbp
The Dobuffer () method
The Dobuffer () method would 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 would be declared and sent from our MethodName () method, which'll be covered later in this
Article.
Private Sub Dobuffer (ByRef strbuffer As String, ByRef lngbuffer as Long, ByVal addstring as String)
Notice that this dobuffer () 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 is declared for internal use.
Dim Strhold as String
Dim Lngindex as Long
Now our a business would be to determine whether we are large enough to hold the string
Data we want to it. But before we do it, 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 does this is 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
The overall buffer size.
If Lngbuffer + len (addstring) > Len (strbuffer) Then
If the is large enough to fit the sent string, then the code discussed next'll be skipped. This
Would occur more often than not since we ' ll set our string buffer to hold a large amount of data when we

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.