substring并返回特定字符后的值

时间:2012-06-21 02:10:52

标签: vb.net substring

“Testing.BSMain,Text:Start Page”

我想将上面的值子字符串并仅返回vb.net中“:”之后的值。我怎么能这样做?

3 个答案:

答案 0 :(得分:19)

假设没有错误检查:

Dim phrase As String = "Testing.BSMain, Text: Start Page".Split(":")(1)

简单地用冒号分割短语并返回第二部分。

要使用SubString,请尝试:

Dim test As String = "Testing.BSMain, Text: Start Page"
Dim phrase As String = test.Substring(test.IndexOf(":"c) + 1)

答案 1 :(得分:8)

您可以使用split方法在冒号

之后返回值
   Dim word as String  = "Testing.BSMain, Text: Start Page"
   Dim wordArr as String()  = word.Split(":")
   Dim result as String = wordArr(1);

答案 2 :(得分:0)

如果提出的解决方案对您不起作用,我是这样做的:

result= Split("Testing.BSMain, Text: Start Page", ":")(1)