-1

I try to learn xojo. Is there any method Startswith in xojo just like in Java and Vb.net? If there is, how should I implement it? Thank you.

2 Answers2

1

In the old framework there is no equivalent so you will have to code it yourself using Left.

Strings in Xojo are, by default, case insensitive and this would work:

Function BeginsWith(extends aString as string, startString as String) As Boolean  
  Return ( Left( aString, len( startString))=startString )
End Function

If you want case sensitivity you could so this:

Function BeginsWithNoCase(extends aString as string, startString as String) As Boolean
  dim s1,s2 as string
  s1 = Uppercase( aString)
  s2 = Uppercase( startString)
  Return ( Left( s1, len( s2))=s2 )
End Function

This and more at https://forum.xojo.com/19302-is-there-method-startswith-in-xojo/0#p162011

BKeeney Software
  • 1,299
  • 6
  • 8
1

Use Text.BeginsWith. It supports both case-insensitive and case-sensitive comparisons.

Paul Lefebvre
  • 6,253
  • 3
  • 28
  • 36