所以我有一个文本框数组列表,我想总结一下它的所有值。在此代码中,仅添加了最后一个文本框。我该怎么办?我想为每个做一个,但我不知道正确的代码。我需要一些帮助。
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
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()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句