2010-10-29 67 views
0

我在文本框中有文本。內容是「10/BSC/01」。vb.net文本框控件

「10」=本年度

「BSC」=部門

「01」=學生

的卷數。如果我按下一個命令按鈕,在 「01」 應該沒有遞增影響其他領域。

我該怎麼辦?

+0

這是所有將要字符串操作:)閱讀這些網頁http://www.homeandlearn.co.uk/net/nets7p1.html/http://www.vbtutor.net/lesson13.html – 2010-10-29 04:39:10

回答

0

僞代碼:

暗淡ARRY = textbox.text.split( 「/」)
昏暗NUM = CTYPE(ARRY(2),INT)
NUM + = 1
numstr = num.tostring (前綴爲0)
textbox.text = arry(0)+「/」+ arry(1)+「/」+ numstr

0

您可以使用regular expression來提取元素。

Dim input As String = "10/BSC/01" 
Dim matches As MatchCollection = Regex.Matches(input, "(\d+)/(\w+)/(\d+)") 

Dim year As Integer = Integer.Parse(matches(0).Groups(1).Value) 
Dim course As String = matches(0).Groups(2).Value 
Dim rollNumber As Integer = Integer.Parse(matches(0).Groups(3).Value) 

Dim result As String = String.Format("{0}/{1}/{2}", year + 1, course, rollNumber)