Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

extracting Substrings from Multiline textbox

$
0
0
Hi
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?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>