Use split to convert the rule string to an array, and use VB6 for join

Source: Internet
Author: User
The parameter of the join function is an array and a separator (Optional). It imports all elements of the array to a string. The elements are separated by separators and the string is returned. For example Code Returns the following strings: 1, 2, 3, 4, 5. Dim Testarr ( 0   To   4 ) As Variant

Testarr ( 0 ) =   1
Testarr ( 1 ) =   2
Testarr ( 2 ) =   3
Testarr ( 3 ) =   4
Testarr ( 4 ) =   5
Debug. Print Join (Testarr, " , " ))

The parameter of the split function is a string, a separator (optional), the number of returned substrings, and a comparison method. This function returns a zero-based array with a substring as an array element. The following code uses the string generated in the preceding example as the parameter of the split function. The split function restores an array. Dim Strtest As   String
Dim Testarr As Variant

Strtest =   " 1, 2, 3, 4, 5 "
Testarr =   Split (Strtest, " , " )
Dim I As   Integer
For I = 0   To   Ubound (Testarr)
Print Testarr (I)
Next

The join and split functions are very useful when you need to convert the array content to a string and restore the array from the string. For example, convert the width of each column of the table to a string and save it to the Registry. Then, restore the column width from the registry. Using these two functions simplifies the storage and processing of array content.

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.