VB.NET字符串操作 [英] VB.NET String manipulation
本文介绍了VB.NET字符串操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有
Hi,
I have
Textbox1.text= "Kumar, Ravi (Customer - Back office) - C088888"
我想从上面的字符串中获取"C088888",其后是最后一个-"字符串.请让我知道如何获取此字符串?
谢谢&问候
Care Career
I want to fetch "C088888" from above string wherein it is followed by last " - " string.Please let me know how can i get this ?
Thanks & Regards
Care Career
推荐答案
试试这个代码.我在您的字符串上对其进行了测试,并获得了所需的结果:
Hi,
try this code. I tested it on your string and got your desired result:
Private Sub Form1_Load(sender As Object, e As EventArgs)
Textbox1.Text = "Kumar, Ravi (Customer - Back office) - C088888"
Dim res As String() = Textbox1.Text.Split("-"C)
If res.Length >= 2 Then
Dim number As String = res(res.Length - 1).Replace(" ", "")
MessageBox.Show(number)
End If
End Sub
这篇关于VB.NET字符串操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文