SandyR
May 29th, 2003, 02:32 PM
Hi,
I use VB.NET and ASP.NET.
I'm trying to use IndexOf for search a substring. I use this function a lot but never functions to me.
I want the index of the begin and end of a substring but always return 0 even is the substring exist.
My strSource have several CR-LF inside.
What I'm doing wrong?
Thanks in advance, Sandy
PS:
The code follows:
Private Function FindSubstring(ByVal strSource As String) As String
Dim intBegin As Integer = 0
Dim intEnd As Integer = 0
If intBegin = strSource .IndexOf("StringSearched: ") <= 0 Then
Return 0
End If
' I want to consider the position after the :
intBegin = strSource .IndexOf(" ", intBegin)
' Find the position of carriage return-line feed
If intEnd = strSource .Substring(intBegin ).IndexOf(vbCrLf) <= 0 Then
Return 0
End If
Return strSource.Substring(intBegin, intEnd - intBegin - 1)
End Function
I use VB.NET and ASP.NET.
I'm trying to use IndexOf for search a substring. I use this function a lot but never functions to me.
I want the index of the begin and end of a substring but always return 0 even is the substring exist.
My strSource have several CR-LF inside.
What I'm doing wrong?
Thanks in advance, Sandy
PS:
The code follows:
Private Function FindSubstring(ByVal strSource As String) As String
Dim intBegin As Integer = 0
Dim intEnd As Integer = 0
If intBegin = strSource .IndexOf("StringSearched: ") <= 0 Then
Return 0
End If
' I want to consider the position after the :
intBegin = strSource .IndexOf(" ", intBegin)
' Find the position of carriage return-line feed
If intEnd = strSource .Substring(intBegin ).IndexOf(vbCrLf) <= 0 Then
Return 0
End If
Return strSource.Substring(intBegin, intEnd - intBegin - 1)
End Function