String Functions

alfcen

Well-Known Member
Licensed User
Longtime User
I know Christmas is over, but here a small honey list:

1. StrSplit(myString)
2. ToProperCase(myString)
 
D

Deleted member 103

Guest
Hi alfcen,

from Online-Help:
Splits the given text around matches of the pattern.
Example:
Dim components() As String
components = Regex.Split(",", "abc,def,,ghi") 'returns: "abc", "def", "", "ghi"

which means "ToProperCase" ?

Ciao,
Filippo
 

alfcen

Well-Known Member
Licensed User
Longtime User
Ciao Filippo,

Hope you are doing fine.
RegEx is nice but I always try to use a minimum set of libraries.

"ToProperCase" would convert the first letter of a word to a Capital letter.
Sure there is a work-around, but I prefer short source codes :icon_clap:

Anyway, herzlichen Dank
Robert
 

Heinz

Active Member
Licensed User
Longtime User
I need a code, if a string is
into another string, like
If Instr(mystr, stringtocompare)
If Instr("abcdef", "cd")

How can i get it with .CompareTo() ?
 

lawboy

Member
Licensed User
Longtime User
Is there an example of the workaround to have a text box do proper case?

Thanks
 

alfcen

Well-Known Member
Licensed User
Longtime User
ToProperCase

Please try this:

B4X:
Log(ToProperCase("this is supposed to be proper case"))

Sub ToProperCase(myStr As String) As String
   Dim x As String
   Dim j, k As Int
   x = myStr.ToUpperCase.CharAt(0)
   myStr = x & myStr.SubString2(1, myStr.Length)
   For j = 1 To myStr.Length
      k = myStr.IndexOf2(" ", j + 1)
      If k = -1 Then Exit
           x = myStr.ToUpperCase.CharAt(k + 1)
      myStr = myStr.SubString2(0, k + 1) & x & myStr.SubString2(k + 2, myStr.Length)
   Next
    Return myStr 
End Sub
 
Top