Hi, I need to be able to extract a piece if text between two delimiters, i.e. if the 'text' string is something like '/this is one/this is two/this is three/this is four' I need to be able to define the delimiter as '/' and then have the code extract a piece of the data.
In VB6 I'd create a Function
Function Piece(sSource As String, sDelimiter As String, iPiece As Integer)
Dim s As String
s = sSource + sDelimiter
Dim i As Integer
Dim iDelPos As Integer
If iPiece > 1 Then
For i = 1 To iPiece - 1
iDelPos = InStr(s, sDelimiter)
s = Mid(s, iDelPos + 1, Len(s))
Next i
End If
If s = "" Then
Piece = ""
Else
Piece = Mid(s, 1, InStr(s, sDelimiter) - 1)
End If
End Function
And then to extract say the third piece of data from the I'd simply execute the following
dim TextExtract as string
TextExtract = Piece(text, "/",3)
and TextExtract would = 'this is three'
is this possible in B4A
In VB6 I'd create a Function
Function Piece(sSource As String, sDelimiter As String, iPiece As Integer)
Dim s As String
s = sSource + sDelimiter
Dim i As Integer
Dim iDelPos As Integer
If iPiece > 1 Then
For i = 1 To iPiece - 1
iDelPos = InStr(s, sDelimiter)
s = Mid(s, iDelPos + 1, Len(s))
Next i
End If
If s = "" Then
Piece = ""
Else
Piece = Mid(s, 1, InStr(s, sDelimiter) - 1)
End If
End Function
And then to extract say the third piece of data from the I'd simply execute the following
dim TextExtract as string
TextExtract = Piece(text, "/",3)
and TextExtract would = 'this is three'
is this possible in B4A