Dim equation As String
Dim numbers() As String
Dim operators As New List(Of String)
Dim result As Double
Dim rx As New Regex("(\+|\-|\*)+")
Dim matches As MatchCollection
equation = TextBox1.Text
numbers = equation.Split(New String() {"+"c, "-"c, "*"c}, StringSplitOptions.None)
matches = rx.Matches(equation)
Dim m1 As Match
For Each m1 In matches
operators.Add(m1.Value)
Next
result = CInt(numbers(0))
Dim i As Integer
For i = 1 To numbers.GetUpperBound(0)
Select Case operators(i - 1)
Case "*"
result *= CDec(numbers(i))
Case "+"
result += CDec(numbers(i))
Case "-"
result -= CDec(numbers(i))
Case " ^"
result ^= CDec(numbers(i))
End Select
Next
MessageBox.Show(result)
That's my code, for example "1+4+2*3" how can i edit my code to start with the multiplication first and division then + and - . Does someone have an idea?