• <tfoot id='el5Ix'></tfoot>
    <legend id='el5Ix'><style id='el5Ix'><dir id='el5Ix'><q id='el5Ix'></q></dir></style></legend>
    <i id='el5Ix'><tr id='el5Ix'><dt id='el5Ix'><q id='el5Ix'><span id='el5Ix'><b id='el5Ix'><form id='el5Ix'><ins id='el5Ix'></ins><ul id='el5Ix'></ul><sub id='el5Ix'></sub></form><legend id='el5Ix'></legend><bdo id='el5Ix'><pre id='el5Ix'><center id='el5Ix'></center></pre></bdo></b><th id='el5Ix'></th></span></q></dt></tr></i><div id='el5Ix'><tfoot id='el5Ix'></tfoot><dl id='el5Ix'><fieldset id='el5Ix'></fieldset></dl></div>

    1. <small id='el5Ix'></small><noframes id='el5Ix'>

        • <bdo id='el5Ix'></bdo><ul id='el5Ix'></ul>

        在 VB6 中订阅 C# .net 事件

        Subscribe to C# .net Event in VB6(在 VB6 中订阅 C# .net 事件)
        <legend id='pjwwP'><style id='pjwwP'><dir id='pjwwP'><q id='pjwwP'></q></dir></style></legend>

            <i id='pjwwP'><tr id='pjwwP'><dt id='pjwwP'><q id='pjwwP'><span id='pjwwP'><b id='pjwwP'><form id='pjwwP'><ins id='pjwwP'></ins><ul id='pjwwP'></ul><sub id='pjwwP'></sub></form><legend id='pjwwP'></legend><bdo id='pjwwP'><pre id='pjwwP'><center id='pjwwP'></center></pre></bdo></b><th id='pjwwP'></th></span></q></dt></tr></i><div id='pjwwP'><tfoot id='pjwwP'></tfoot><dl id='pjwwP'><fieldset id='pjwwP'></fieldset></dl></div>
              <tbody id='pjwwP'></tbody>

          1. <tfoot id='pjwwP'></tfoot>
            • <small id='pjwwP'></small><noframes id='pjwwP'>

              • <bdo id='pjwwP'></bdo><ul id='pjwwP'></ul>
                  本文介绍了在 VB6 中订阅 C# .net 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要能够在 VB6 中处理 .net 事件.到目前为止,我通过使我的 c# 类 COM 可见来设置它.我的 VB6 对象可以很好地调用它的方法,但现在我需要某种方式从 .net 到 VB 进行通信.如果我向我的 c# 类添加一个事件,.net 包装器似乎添加了一个 add_EventName 和 remove_EventName 我假设这是订阅和取消订阅该事件.但是当谈到 VB6 时,我仍然是一个新手,所以我不太确定如何使用它.

                  I need to get be able to handle a .net event in VB6. So far i have it set up by making me c# class COM visible. My VB6 object can call methods on it fine but now i need some way to communicate from .net to VB. If i add an event to my c# class the .net wrapper seems to add an add_EventName and remove_EventName which i assume this is to subscribe and unsubscribe to the event. But i'm still a novice when it comes to VB6 and come so i'm not really sure how to use it.

                  add_EventName 似乎需要一个 EventNameEventHadler 但我给它什么呢?我尝试了 sub 但这给了我一个运行时错误.有谁知道如何使用这个?这是我所拥有的示例

                  The add_EventName seems to take an EventNameEventHadler but what do i give it? i tried the sub but this gives me a runtime error. Anyone know how to use this? Here is an example of what i have

                  Private oHost As HostService.IHost
                  
                  Private Sub Form_Load()
                      Set oHost = New HostService.Host
                      oHost.Start
                      oHost.add_EvalReceived EvalReceivedEventHandler
                  End Sub
                  
                  Private Sub EvalReceivedEventHandler(ByVal sender As Variant, ByVal e As EvalReceivedEventArgs)
                  MsgBox "Eval Received in VB: " & e.Eval.TimeSent & ":" & e.Eval.FirstName & " " & e.Eval.LastName & " - " & e.Eval.Comments
                  End Sub
                  

                  所以 oHost.add_EvalReceived 行是错误的

                  So oHost.add_EvalReceived line is wrong

                  推荐答案

                  您可以尝试将 WithEvents 添加到您的 oHost

                  You could try adding WithEvents to your declaration of oHost

                  Private WithEvents oHost As HostService.IHost
                  

                  那么 IDE 应该允许您在 oHost 上创建事件处理程序.这就像制作您的 Form_Load 事件处理程序一样.代码窗口左上角的下拉菜单应该让您选择 oHost.

                  Then the IDE should allow you to create event handlers on oHost. It's just like making your Form_Load event handler. The drop-down at the top-left of the code window should let you select oHost.

                  免责声明:我已经多次使用它来处理来自 COM 对象的事件.我实际上从未尝试过通过互操作处理来自 .Net 对象的事件,但我认为您必须这样做.

                  Disclaimer: I've used this many times to handle events from COM objects. I've never actually tried handling events from a .Net object through interop, but I would think you must do it like this.

                  这篇关于在 VB6 中订阅 C# .net 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  How can I force the PropertyGrid to show a custom dialog for a specific property?(如何强制 PropertyGrid 显示特定属性的自定义对话框?)
                  Associate attribute with code generated property in .net(将属性与 .net 中的代码生成属性相关联)
                  Attribute to generate compilation error on method call?(在方法调用上生成编译错误的属性?)
                  Can you omit the parenthesis from attributes with no params?(您可以省略没有参数的属性中的括号吗?)

                  <small id='z4EXa'></small><noframes id='z4EXa'>

                      <tbody id='z4EXa'></tbody>

                        <i id='z4EXa'><tr id='z4EXa'><dt id='z4EXa'><q id='z4EXa'><span id='z4EXa'><b id='z4EXa'><form id='z4EXa'><ins id='z4EXa'></ins><ul id='z4EXa'></ul><sub id='z4EXa'></sub></form><legend id='z4EXa'></legend><bdo id='z4EXa'><pre id='z4EXa'><center id='z4EXa'></center></pre></bdo></b><th id='z4EXa'></th></span></q></dt></tr></i><div id='z4EXa'><tfoot id='z4EXa'></tfoot><dl id='z4EXa'><fieldset id='z4EXa'></fieldset></dl></div>

                          <legend id='z4EXa'><style id='z4EXa'><dir id='z4EXa'><q id='z4EXa'></q></dir></style></legend>
                        • <tfoot id='z4EXa'></tfoot>
                          • <bdo id='z4EXa'></bdo><ul id='z4EXa'></ul>