Mid and Instr Functions in B4A

Darren69

Member
Licensed User
Longtime User
Hi,

I am really new to B4A, and have been reading the guides and searching the forums but am finding conflicting information, or maybe i am just not understanding it properly.

I have been writing code in RealBasic for years, and have so far found it really easy to us B4A but this line of code from an application I am trying to port over has me slightly confused.

CleanString = Mid(Data,inStr(Data,KeyStart)+Len(KeyStart),InStr(Data,KeyEnd)-(Instr(Data,KeyStart) +Len(KeyStart)))

as I get the error "Error description: Undeclared variable 'mid' is used before it was assigned any value."

my questions is how do I need to modify the above code to work with B4A?

I tried changing the MID to Substring2 but got the same error, I believe that Substring2 is the same as Mid.

Sorry if the answer is obvious, but I have yet to find it.

thanks

Darren
 

Darren69

Member
Licensed User
Longtime User
Thanks for that, the prod in the right direction was just what I needed, I now have a better understanding of the native B4A String functions.
 
Upvote 0

Felippy Rocha

New Member
Licensed User
Longtime User
insrt like vb6.

Sub instr(rInicio As Int , rString As String , rStringProc As String) As Int
Dim i As Int
Dim str As StringFunctions
For i = rInicio To str.len(rString)

If str.mid(rstring,i, str.Len( rStringProc)) = rStringproc Then
Return i
End If

Next

Return 0

End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

netsistemas

Active Member
Licensed User
Longtime User
show previous link for more information.


text.IndexOf(string)
 
Upvote 0
Top