VB-obtain the number of times a character appears in it

Source: Internet
Author: User
1' Method 1: 2 dim STR as string 3 StR = "12345678" 4 msgbox (ubound (split (STR, "3") 5 6' Method 2: 7 dim N &, J & 8 J = 0 9 N = instr (1, text1.text, "/itemname") 10 while n <> 011 n = instr (n + 1, text1.text, text2.text) 12 J = J + 113 Wend 14 print (j) 15 16 17 'method 'call strcount (textbox8.text, "/itemname ") 19 20 function strcount (byval stra as string, byval strb as string) as long21 dim lnga as long22 dim lngb as long23 dim lngc as long24 lnga = Len (stra) 25 lngb = Len (strb) 26 lngc = Len (replace (stra, strb, "") 27 strcount = (lnga-lngc)/lngb28 msgbox (strcount) 29 30 31 end Function

 

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.