Hi
I tried to extract some substrings from a multiline textbox using the Instr function, But it is not working...
As I have mentioned in between, When I output the Lonstart variable, all it gives is the value of Start variable.
Is there something wrong with the code? Is there any other way to do the task?
I tried to extract some substrings from a multiline textbox using the Instr function, But it is not working...
Private Function GetBetween(ByVal Start As Long, Data As String, Startstr As String, Endstr As String) As String
Dim lonstart As Long, lonend As Long
lonstart = InStr(1, Data, StartString, vbTextCompare)
MsgBox lonstart 'Not modifing Lonstart
If lonstart > 0 Then
lonstart = lonstart + Len(StartString)
lonend = InStr(lonstart, Data, EndString, vbTextCompare)
If lonend > 0 Then
GetBetween = Mid$(Data, lonstart, lonend - lonstart)
End If
End If
End Function
As I have mentioned in between, When I output the Lonstart variable, all it gives is the value of Start variable.
Is there something wrong with the code? Is there any other way to do the task?