在另一个类中调用过程 [英] Calling a procedure within another class
问题描述
我为Outlook 2010创建了一个加载项.我有一个功能区,上面有一个按钮.当您单击该按钮时,我希望它在ThisAddIn.vb中调用一个过程.
I've created an add-in for outlook 2010. I have a ribbon that has a button on it. When you click that button, I want it to call a procedure in the ThisAddIn.vb.
有两个文件:ThisAddin.vb和Ribbon.vb.
There are two files: ThisAddin.vb and Ribbon.vb.
我尝试了几项都无济于事.我还将所有程序设置为公开.
I've tried several things to no avail. I've also set all the procedures to public.
致电Testing123()
Call Testing123()
调用ThisAddIn.Testing123()
Call ThisAddIn.Testing123()
等
如何正确调用此过程?
****Ribbon1.vb****
Imports Microsoft.Office.Tools.Ribbon
Public Class MyOutlookTab
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click
Call Testing123()
End Sub
End Class
***ThisAddIn.vb***
Public Class ThisAddIn
Public Sub Testing123()
System.Windows.Forms.MessageBox.Show("It Works!")
End Sub
End Class
推荐答案
Thanks for everyones comments but I found the solution in an example here: http://msdn.microsoft.com/en-us/library/ee620548.aspx where they talk about adding a ribbon to the meeting request (2/3's of the way down).
实际上很简单.您使用全局"调用该过程
It's actually quite simple. You call the procedure using the "Global"
Globals.ThisAddIn.Testing123()
不需要其他任何东西.
这篇关于在另一个类中调用过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!