none
vsto 中一段c#代码求转为VB RRS feed

  • 问题

  • private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.WindowSelectionChange += new Word.ApplicationEvents4_WindowSelectionChangeEventHandler(Application_WindowSelectionChange);
            }

    void Application_WindowSelectionChange(Word.Selection Sel)
            {
                }
            }

    转为VB是啥代码?虚心求教


    • 已编辑 wfligm 2015年7月8日 7:21
    2015年7月8日 6:55

答案

  • 你好,

    VB中绑定事件是通过AddHandler 和AddressOf。

    你可以参考下面的文档:https://msdn.microsoft.com/zh-cn/library/6yyk8z93(v=vs.90).aspx

    我帮你改了一下,你可以参考。

    Private Sub ThisAddIn_Startup(sender As Object, e As System.EventArgs)
    	AddHandler Me.Application.WindowSelectionChange, AddressOf New Word.ApplicationEvents4_WindowSelectionChangeEventHandler(AddressOf Application_WindowSelectionChange)
    End Sub
    
    Private Sub Application_WindowSelectionChange(Sel As Word.Selection)
    End Sub


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年7月9日 2:52
    版主