VB.NET解決方案:
如果你只是需要從生成的字符串第9號你可以使用String.Substring,即:
Dim numberString as String = "6389178720"
Dim newString As String = numberString.Substring(0, 9)
MessageBox.Show(newString)
顯示638917872
MSDN Link
編輯:
也許y OU會想使用正則表達式 - 這樣的事情也許可以讓你開始:
Private Sub Input()
Dim numberString As String = "Order Confirmation # 638917872-001 Partial Order/$23.74 RECEIVED"
Dim numberString2 As String = "Order Confirmation - Multiple Orders - Order Confirmation#639069135-001/$297.45 - Order Confirmation#639069611-001/$32.08"
GiveMeTheNumbers(numberString)
GiveMeTheNumbers(numberString2)
End Sub
Function GiveMeTheNumbers(ByVal s As String) As String
Dim m As Match = Regex.Match(s, "6\d{8}") 'get 9 digit #s begin w/6
Do While m.Success
MessageBox.Show(m.Value.ToString)
m = m.NextMatch()
Loop
Return False
End Function
結果 - MessageBox1:638917872 MessageBox2:639069135 MessageBox3:639069611
它是從6還是從#6開始? – dbasnett