2013-03-24 146 views
0

我正在使用Infopath和VBA,並面臨一個小問題。我試着搜索這個,發現了一些例子,但不能正確理解它們(作爲新手)。單擊按鈕觸發多個按鈕單擊

我真的很感激,如果有人能把我推向正確的方向。

我想通過點擊一個名爲MasterSumbit

我在InternalStartup部分

Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup 
    AddHandler DirectCast(EventManager.ControlEvents("Button1"), ButtonEvent).Clicked, AddressOf Button1_Clicked 
    AddHandler DirectCast(EventManager.ControlEvents("Button2"), ButtonEvent).Clicked, AddressOf Button2_Clicked 
    ...and such for button 3 and 4 
    AddHandler DirectCast(EventManager.ControlEvents("MasterSubmit"), ButtonEvent).Clicked, AddressOf MasterSubmit_Clicked 
    End Sub 

加載的事件處理程序按鈕來完成的四個按鈕(button1,2,3,4)執行代碼這是在MasterSubmit按鈕

Public Sub MasterSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs) 

    Button1_Clicked.click() 
    Button2_Clicked.click() 
    Button3_Clicked.click() 
    Button4_Clicked.click() 

    End Sub 

我收到以下錯誤,每個按鈕的Click事件的代碼

Argument not specified for parameter 'e' of 'Public Sub Button1_Clicked(sender As Object, e As Microsoft.Office.InfoPath.ClickedEventArgs)'. 
Argument not specified for parameter 'sender' of 'Public Sub Button1_Clicked(sender As Object, e As Microsoft.Office.InfoPath.ClickedEventArgs)'. 

感謝預期

+0

您是否在運行時添加了四個按鈕?如果沒有,你不能只是'Private Sub AnyButton_Click(sender As System.Object,e As System.EventArgs)Handles Button1.Click,Button2.Click,Button3.Click,Button4.Click'? – 2013-03-24 15:10:32

+0

此外,你應該重新標記你的問題VB.Net。這絕對不是VBA :)。 – 2013-03-24 15:15:44

+0

我曾嘗試把這個內部啓動部分後,但不工作。我很確定我做錯了! – user2204330 2013-04-27 06:30:15

回答

1

試試這個:

Public Sub MasterSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs) 

Button1_Clicked.click(sender, e) 
Button2_Clicked.click(sender, e) 
Button3_Clicked.click(sender, e) 
Button4_Clicked.click(sender, e) 

End Sub 
+0

不工作。相同的錯誤:( – user2204330 2013-03-24 11:50:22

0

會(小組碩士按鈕內),這不是工作?

Button2.PerformClick() 
Button3.PerformClick() etc.... 

希望我幫了忙。