字符串截取 vb.net实现

来源:百度知道 编辑:UC知道 时间:2024/05/24 14:03:56
用VB.NET实现 下面的功能
字符串:“12+78”
提出字符串“12”和“78” 来,
将字符串进行转换,转换成integer类型的,
再进行加法运算。
谢谢了

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim result As String = ""
Dim str As String = TextBox1.Text
Dim substr As String
Dim split() As Char = { "+"}
For Each substr In str.Split(split)
result += substr + ControlChars.CrLf
Next
TextBox2.Text = result
End Sub
上面的代码你试一下,可以根据加号来提取出每一个数字,这就是你所要求的核心代码,其余的自己琢磨,呵呵!