标签不在VB中显示文本

时间:2013-02-17 00:14:20

标签: asp.net vb.net visual-studio

我的代码没有在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

1 个答案:

答案 0 :(得分:0)

EquationValues是一个数组,检查长度不是我认为你正在寻找的。您正在寻找计数...数组中的索引数...尝试

For LoopCounter = 0 To EquationValues.Count - 1

我回答了关于字符串解析数学方程(parsing string to equation with vb)的前一个问题。这个例子处理了*和/,也许这可能对你有用。

祝你好运:)