Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NETstrings
Hai all,
I am developing one VB Application in VS2010. In that i am using Mid() for getting the string, but here we need to give an start position(Integer) and length of string(integer).
But i need to get the string between two characters .... Is it possible?
For Example:
String= "CHimaN"
I want the string in Between Chars C and N
How i get Hima As my string....
Please give me a solution.......
Waiting for ur response................
Posted 3-Jan-12 18:45pm
Edited 3-Jan-12 20:32pm
SAKryukov at 4-Jan-12 1:11am
...and, more exactly, what do you need to do? --SA
Himachandra at 4-Jan-12 1:14am
I need to get the string between two chars..... Just like String--- CHimaM i need the String Between Chars C & M ie., Hima How can i get that in VB
Reiss at 4-Jan-12 3:17am
Do you need to account for multiple instances of either <b>C</b> or <b>M</b>, e.g. <b>CdddMCssMMC</b>
Himachandra at 4-Jan-12 4:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Dim source As String = "CHimaM"
Dim extract As String = ""
Dim start As Integer = source.IndexOf("C"C) + 1
Dim [end] As Integer = source.IndexOf("M"C)
If start >= 0 AndAlso [end] > start Then
    extract = source.Substring(start, [end] - start)
End If
Himachandra at 5-Jan-12 23:38pm
Yah Itz working..... Thank You Mr OriginalGriff
OriginalGriff at 6-Jan-12 3:28am
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 696
1 OriginalGriff 478
2 Tadit Dash 400
3 sanket saxena 337
4 Peter Leow 228
0 Sergey Alexandrovich Kryukov 11,890
1 OriginalGriff 7,335
2 Peter Leow 5,003
3 Abhinav S 3,943
4 Maciej Los 3,575

Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 4 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid