Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
midReturn
Author:
MacLeod Broad
Submitted:
2/8/2008
Version:
VB.NET 2003
Compatibility:
VB.NET 2003, VB 2005, VB 2008
Category:
String Manipulation
Views:
10206
Return the substring between two strings. For Example: the phrase "The cow likes to eat green grass in the field." midReturn("to eat "," grass", ""The cow likes to eat green grass in the field.") Would return "green"
Declarations:
'none
Code:
Public Function midReturn(ByVal first As String, ByVal last As String, ByVal total As String) As String If last.Length < 1 Then midReturn = total.Substring(total.IndexOf(first)) End If If first.Length < 1 Then midReturn = total.Substring(0, (total.IndexOf(last))) End If Try midReturn = ((total.Substring(total.IndexOf(first), (total.IndexOf(last) - total.IndexOf(first)))).Replace(first, "")).Replace(last, "") Catch ArgumentOutOfRangeException As Exception End Try End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement