Examples of Filter Array filter functions and Filter functions

Source: Internet
Author: User

Examples of Filter Array filter functions and Filter functions

'*************************************** **********************************

'** Module name: Filter Array Filter function final solution example' ** description: blue Phoenix design mall-sun Phoenix-Guo Wei | Blue Phoenix-magic spirit | Guo Wei-icecept '** created by: Sun Phoenix-Guo Wei' ** Date: october 11, 2015 13:38:55 '** revised by: yuhuo Phoenix-Guo Wei' ** Date: '** Description: QQ: 493405998 | \ Wangwang: icecept' ** version: v1.0.0 | http://blog.sina.com.cn/icecept '*************************************** * ********************************** '● Usage: return array = Filter (original array, the text to be searched, [TRUE if it is contained, otherwise FALSE. the default Value is True], [comparison method]) '● syntax Filter (InputStrings, Value [, Include [, Compare])' special note: the Filter function compares arrays and search objects by string, and determines whether there is a include relation rather than an equal relation. Private Sub Command4_Click () Dim aa As Variant, bb () As String, prt As Variant aa = Array ("Blue Phoenix", "bath fire phoenix", "magic spirit", "Guo Wei ", "icecept", "Long haochen", "San caer", "Zhou Weiqing", "Shangguan Binger", "Shangguan Feier", "Shangguan xueer", "Wu yuehan ", "Dongfang hanyue") bb = Filter (aa, Text1.Text, False) 'displays all projects that do not contain text box input content For Each prt In bb Debug. print prt, Next Debug. printEnd Sub Private Sub Command5_Click () Dim Arr = Array (1, 2, 3, 4, 5, 6, 11, 13, 15, 11, 2, 3, 5) debug. print "original array:" & Join (Arr, ",") & vbCrLf 'true: displays items that contain 1, and False: displays items that do not contain 1, if this option is omitted, the default value is true x = Filter (Arr, 1, False) Debug. print "arrays that do not contain 1:" & Join (x, ",") 'original array, 5' arrays that do not contain 1: 2, 3, 4, 5, 6, 2, 3, 5End Sub Private Sub Form_Load () Me. show Dim x (2) x (0) = "kjwang" x (1) = "wangkj" x (2) = "peter" 'If this parameter is left blank, the default value is True, true: display items with kj. Flase: display items without kj. v = Filter (x, "kj") Print v (0), v (1) 'vbtextcompare are case-insensitive, the default value (vbTextCompare) is case sensitive v = Filter (x, "kj", False) Print v (0) End Sub Private Sub Command2_Click () Dim aa (10) as String Dim bb () As String Dim I As Integer For I = 0 To 9 If I Mod 2 = 0 Then aa (I) = "aa" & Str $ (I) else aa (I) = "bb" & Str $ (I) End If Next I 'true: The item bb = Filter (aa, "aa", True) containing aa in the array is displayed) 'flase display array does not contain aa's item 'bb = Filter (aa, "aa", False) Debug. print Join (bb, ",") End Sub Private Sub commandingly click () Dim Arr = Array (1, 2, 3, 4, 5, 6, 21, 13, 15, 12, 25, 3, 5) Debug. print "original array:" & Join (Arr, ",") & vbCrLf 'true shows items that contain 2, False shows items that do not contain 2, if this option is omitted, the default value is true x = Filter (Arr, 2, True) Debug. print "array containing 2:" & Join (x, ",") 'original array, 5' array containing 2: 2, 21, 12, 25End Sub Private Sub Command3_Click () Dim B () As String Dim a (60) as String Dim I As Integer For I = 0 To 60 a (I) = CStr (I) Next I Debug. print "original array:" & Join (a, ",") & vbCrLf 'true. Only elements containing 5 are attached to array B = Filter (a, 5, True) debug. print "array containing 5:" & Join (B, ",") 'original array,, 58,59, 60'' only contains 5 arrays: 5, 15, 25, 35, 45, 50, 52, 54, 55, 56, 59End Sub

Related Article

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.