سبب المثال هنا
تفضل المثال ....لاول مرة افكر بهذه الطريقة
اولا الاستدعاء
كود :
Imports System.Text.RegularExpressions
كود :
Dim str As String = "([0-9]{1,})([\/ \* \- \+])([0-9]{1,})"
Dim reg As New Regex(str)
Dim ma As Match = reg.Match(TextBox1.Text)
If ma.Success Then
' TextBox2.Text = ma.Groups(1).Value & " " & ma.Groups(2).Value & " " & ma.Groups(3).Value
Select Case ma.Groups(2).Value
Case "/"
TextBox2.Text = Val(ma.Groups(1).Value) / Val(ma.Groups(3).Value)
Case "*"
TextBox2.Text = Val(ma.Groups(1).Value) * Val(ma.Groups(3).Value)
Case "-"
TextBox2.Text = Val(ma.Groups(1).Value) - Val(ma.Groups(3).Value)
Case "+"
TextBox2.Text = Val(ma.Groups(1).Value) + Val(ma.Groups(3).Value)
End Select
End If