Android Question how to get first line stringsin MULTILINE text?

hears

Active Member
Licensed User
Longtime User
how to get first line strings in MULTILINE text?
 

walterf25

Expert
Licensed User
Longtime User
how to get first line strings in MULTILINE text?
it depends, are you reading the string from a file, from a variable etc..
if you're reading the string from a file you can use .ReadLine() in TextReader, otherwise if you're reading the string from a variable, you can check for the Chr(13) character at the end of each line and separate each lines by that character.

Hope this is what you're looking for.

Regards,
Walter
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
First method
B4X:
Dim LineString() As String = Regex.Split(CRLF,MultiLineString)
Log(LineString(0)) ' First line

Second (if you're not sure there are more lines)
B4X:
If MultiLineString.IndexOf(CRLF)>-1 Then FirstLine = MultiLineString.SubString2(0,CRLF) Else FirstLine=MultiLineString

'Third (if you're sure there are more lines)
B4X:
Dim FirstLine As String = MultiLineString.SubString2(0,CRLF)
 
Upvote 0

hears

Active Member
Licensed User
Longtime User
THINK YOU )
I have do it ,by stringfunction libary and CHAR(13)

this is my code,TEXTS is my mutiline TEXT
B4X:
Dim str2 As StringFunctions
FIRSTLINE=str2.Trim(str2.SplitGetWord(TEXTS,Chr(13),1))
 
Upvote 0
Top