我可以在两个字符或两个字符串之间使用字符串吗? [英] Can I take String between two Chars or Two Strings

查看:95
本文介绍了我可以在两个字符或两个字符串之间使用字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在VS2010中开发一个VB应用程序.在这种情况下,我正在使用Mid()获取字符串,但是在这里我们需要给出起始位置(整数)和字符串的长度(整数).
但是我需要得到两个字符之间的字符串....有可能吗?
怎么......?
例如:
字符串="CHimaN"
我想要在字符C和N之间的字符串
我如何获得Hima作为我的弦....

请给我一个解决方案.......
等待您的响应................

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?
How.....?
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................

推荐答案

尝试:
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


这篇关于我可以在两个字符或两个字符串之间使用字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆