所以我有一个文本框的数组列表,我想总结它的所有价值。在这段代码中,它只是为最后一个文本框添加。我可以这样做吗?我想为每个人做一个但我不知道正确的代码。我需要一些帮助。
Private Sub boxunitpricecom(ByRef boxpoqty As TextBox, ByRef boxpounitprice As TextBox, ByRef boxpoamount As TextBox)
'MessageBox.Show("right")
Dim var1 As String
Dim var2 As String
Dim var3 As String
Dim var4 As String
Dim amount As String
Try
var1 = Val(boxpoqty.Text)
var2 = Val(boxpounitprice.Text)
var3 = var1 * var2
boxpoamount.Text = var3
'var4 = boxpoamount.Text
'amount = Val(var4) + Val(var4)
' txttotalamount.Text = amount
Dim arrLst As New ArrayList
Dim dblVal As Double
dblVal = 0.0
For i = 0 To arrLst.Count - 1
dblVal = dblVal + boxpoamount.Text
Next
|
Catch ex As Exception
MsgBox(ex.Message)
Finally
cmd.Dispose()
conn.Close()
End Try
End Sub
答案 0 :(得分:0)
Dim txt As TextBox
Dim Sum As Integer
For I = 1 To TextboxCount
txt = CType(Me.Controls("TextBox" + I.ToString()), TextBox) 'the name property of textbox
Sum = Sum + Integer.Parse(txt.Text)
Next I
Output.Text = Sum.ToString()