我有一个我创建的程序,结果不合适,我想在数字行 -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