我在文本框中有文本。内容是“10/BSC/01”。vb.net文本框控件
“10”=本年度
“BSC”=部门
“01”=学生
的卷数。如果我按下一个命令按钮,在 “01” 应该没有递增影响其他领域。
我该怎么办?
我在文本框中有文本。内容是“10/BSC/01”。vb.net文本框控件
“10”=本年度
“BSC”=部门
“01”=学生
的卷数。如果我按下一个命令按钮,在 “01” 应该没有递增影响其他领域。
我该怎么办?
伪代码:
暗淡ARRY = textbox.text.split( “/”)
昏暗NUM = CTYPE(ARRY(2),INT)
NUM + = 1
numstr = num.tostring (前缀为0)
textbox.text = arry(0)+“/”+ arry(1)+“/”+ numstr
您可以使用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)
这是所有将要字符串操作:)阅读这些网页http://www.homeandlearn.co.uk/net/nets7p1.html/http://www.vbtutor.net/lesson13.html – 2010-10-29 04:39:10