1

首先,我一直在这里和那里用谷歌搜索,你被卡住了,我需要有人帮忙。我已经有一个包含函数作为参数的子,现在的问题是我如何在我的按钮中调用这个子,请向我充分解释,我已经很绝望了

Public Function AddDec(ByVal Valdec1 As Decimal, ByVal Valdec2 As Decimal) As Decimal
    AddDec = Valdec1 + Valdec2
End Function

Sub Finished(ByVal AddDec As Func(Of Decimal, Decimal, Decimal))
    If DetailCount1.Text.Length >= 10 Or DetailCount2.Text.Length >= 10 Then
        If TextBox1.Text = "" Then TextBox1.Text = 0
        If DetailCount1.Text.Contains(",") Or DetailCount2.Text.Contains(",") Then
            Valdec2 = CDec(TextBox1.Text)
            TextBox1.Text = Adddec(Valdec1, Valdec2)
            MsgBox("HELP ME xD")
        Else
            ValDbl2 = CDbl(TextBox1.Text)
            TextBox1.Text = ValDbl1 + ValDbl2
        End If
    ElseIf Not DetailCount1.Text.Length >= 10 And Not DetailCount2.Text.Length >= 10 Then
        If TextBox1.Text = "" Then TextBox1.Text = 0
        If kindbil1 = "Even" And Label2.Text = "Even" Then
            val2 = CInt(TextBox1.Text)
            TextBox1.Text = CInt(val1 + val2)
        ElseIf kindbil1 = "Deci" And Label2.Text = "Deci" Then
            Valdec2 = CDec(TextBox1.Text)
            TextBox1.Text = CDec(Valdec1 + Valdec2)
        ElseIf kindbil1 = "Deci" And Label2.Text = "Even" Then
            val2 = CInt(TextBox1.Text)
            Valdec2 = CDec(val2)
            TextBox1.Text = CDec(Valdec1 + Valdec2)
        ElseIf kindbil1 = "Even" And Label2.Text = "Deci" Then
            Valdec2 = CDec(TextBox1.Text)
            Valdec1 = CDec(val1)
            TextBox1.Text = CDec(Valdec1 + Valdec2)
        End If
    End If

End Sub
4

1 回答 1

1

有点难以理解你想要做什么,但我想你想FinishedAddDec方法作为参数的AddDec参数来调用。

为此,您必须使用运算AddressOf

Finished(AddressOf AddDec)
于 2012-10-26T12:37:31.760 回答