Android Question b4a for ubounds to find how many items are in a sting

Discussion in 'Android Questions' started by KRkakao, Jan 9, 2017.

  1. KRkakao

    KRkakao Member

    I cant Find it!

    b4a for ubounds to find how many items are in a string?

    VB6 Source

    msgbox ubound("aaagfjgkjgkjgkjgkj","a")

    Result:

    msgbox 3

    What function can I use to fix it? :(
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Log(CountOccurrences("aaagfjgkjgkjgkjgkj","a"))


    Sub CountOccurrences (Text As String, SearchFor As StringAs Int
       
    Dim count As Int
       
    Dim i As Int = Text.IndexOf(SearchFor)
       
    Do While i > -1
         count = count + 
    1
         i = Text.IndexOf2(SearchFor, i + 
    1)
       
    Loop
       
    Return count
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice