0

Is there a reason why my code is not displaying the text in AnswerText.Text?

    Dim EquationValues() As String

    ' Split the array into a string array based on blank spaces
    EquationValues = DisplayTextBox.Text.Split(" "c)

    ' Declaring an integer as a counter for the loop
    Dim LoopCounter As Integer = 0

        ' Setting a for loop on the array and performing the operations
    For LoopCounter = 0 To EquationValues.Length - 1
        If EquationValues(LoopCounter) = "/" Then
            AnswerTextBox.Text = EquationValues(LoopCounter - 1) / EquationValues(LoopCounter + 1)
        End If

        If EquationValues(LoopCounter) = "*" Then
            AnswerTextBox.Text = EquationValues(LoopCounter - 1) * EquationValues(LoopCounter + 1)
        End If
    Next
toilabav90
  • 15
  • 6

1 Answers1

0

EquationValues is an array, checking the length is not what I think you are looking for. You are looking for the count...the number of indices in the array...try

For LoopCounter = 0 To EquationValues.Count - 1

I answered a previous question of your's regarding string parsing mathematical equations (parsing string to equation with vb). That example handled * and /, perhaps that might have something of use for you.

Good Luck :)

Community
  • 1
  • 1
MonkeyDoug
  • 453
  • 3
  • 17