-1

私が作成したプログラムがありますが、結果が適切ではありません。数字の行 -1、-1、-1 と 1、2、-1 の間で乗算を実行したいです。

-1x1 = -1
-1x2 = -2
-1x-1 = 1

その後、結果が合計されます

(-1) + (- 2) + 1 = -2

解いてください、乗算分 (-)

ここに画像の説明を入力

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click

    Dim Total, Total2 As Integer
    Dim y As Integer = 0
    Dim b As Integer = 2
    Dim getArray As String = TextBox3.Text
    Dim arrVin() As Char = getArray.ToCharArray
    'Dim getArray2 As String = TextBox2.Text
    'Dim arrVin2() As Char = getArray2.ToCharArray
    Dim multArr() As Integer = {1, 2, -1}
    'Dim m As Integer = 1
    'Total = 0
    For Each x As String In arrVin
        If IsNumeric(x) = True Then
            'For Each i As String In arrVin2
            'muliply by a bigger number each time
            'm = 2

            'add the new product to the running total
            'Total = Total + (Val(x) + Val(x))
            'Total2 = (Val(x) * Val(i)) + Total2
            'Total = Total + (m * Val(x))
            Total2 += x * multArr(y)
            y = y + 1
            TextBox1.Text = Total2 + b
        End If
    Next
End Sub
4

1 に答える 1