具有相同签名的多重定义

时间:2015-03-29 03:46:23

标签: vb.net

Dim WithEvents client As New WebClient
Private Sub DirectX9ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DirectX9ToolStripMenuItem.Click
    Try
        client.DownloadFileAsync(New Uri("http://download1588.mediafire.com/y9phz64wph4g/aqlp1m71mvuwo74/Direct+X+11+Update.rar"), "C:\Documents and Settings\All Users\Documents\Direct X 11 Update.RAR")
    Catch ex As Exception
        MsgBox("File already exists or is corrupted!")
    End Try
End Sub

Private Sub client_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles client.DownloadFileCompleted
    MsgBox("Direct X 9 has been successfully downloaded!", MsgBoxStyle.Information)
    Label48.Visible = False
    Label49.Visible = False
    ProgressBar3.Visible = False
    Label48.Text = "0 &"
    Label49.Text = "0 / 0"
    ProgressBar3.Value = 0
End Sub


Private Sub client_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles client.DownloadProgressChanged
    Label48.Visible = True
    Label49.Visible = True
    ProgressBar3.Visible = True
    Label48.Text = ProgressBar3.Value & "%"
    Label49.Text = e.BytesReceived & " / " & e.TotalBytesToReceive
    ProgressBar3.Value = e.ProgressPercentage

End Sub

Private Sub GeForceExperienceV2000ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles GeForceExperienceV2000ToolStripMenuItem.Click

    Try
        client.DownloadFileAsync(New Uri("http://download903.mediafire.com/w91mlqdf6clg/a540a35f5ddcpbn/GeForce_Experience_v2.2.2.0.exe"), "C:\Documents and Settings\All Users\Documents\GeForce_Experience_v2.2.2.0.exe")
    Catch ex As Exception
        MsgBox("File already exists or is corrupted!")
    End Try
End Sub

Private Sub client_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles client.DownloadFileCompleted

    MsgBox("GeForce_Experience_v2.2.2.0 has been successfully downloaded!", MsgBoxStyle.Information)
    Label48.Visible = False
    Label49.Visible = False
    ProgressBar3.Visible = False
    Label48.Text = "0 &"
    Label49.Text = "0 / 0"
    ProgressBar3.Value = 0

End Sub
End Class

1 个答案:

答案 0 :(得分:0)

你在评论中得到了答案,但只是去解释,以确保你明白你能做什么,不能做什么。

当你创建一个方法时,你可以命名它,这样当你调用它时你的程序知道你要调用哪一个。当您为2个方法命名时,它们在调用它时不知道使用哪个方法。

拥有2个具有相同名称的方法的唯一方法是,如果它们具有不同的“签名”,则意味着它不能100%相同。不同的参数会使您的方法的签名不同,即使它们被称为相同的