如何使用不同的容器执行算术运算

时间:2016-11-21 21:23:03

标签: .net vb.net

我的表格中有两个面板。我创建了两个函数来获取所有文本框及其值。我需要一种方法来获取乘法值,即(使用panel1中的第一个文本框乘以panel2中的第一个文本框,依此类推)。

Private Function getallTextBoxes(ByVal container As ContainerControl) As Dictionary(Of String, TextBox)

    Dim allTextBoxes As New Dictionary(Of String, TextBox)

    For Each ctrl As Control In container.Controls
        If TypeOf ctrl Is TextBox Then
            allTextBoxes.Add(ctrl.Name, ctrl)
        End If
    Next
    Return allTextBoxes
End Function


Private Function getTextBoxValues(ByVal textBoxDefs As IDictionary(Of String, TextBox)) As Dictionary(Of String, String)

    Dim textBoxValues As New Dictionary(Of String, String)

    For Each tbxDef As KeyValuePair(Of String, TextBox) In textBoxDefs
        Dim tbx As TextBox = tbxDef.Value
        Dim name As String = tbx.Name
        Dim value As String = tbx.Text
        textBoxValues.Add(name, value)
    Next
    Return textBoxValues
End Function

0 个答案:

没有答案