Microsoft KB Archive/172312: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 87: | Line 87: | ||
<ol> | <ol> | ||
<li>Start Visual Basic 5.0 and create a new ActiveX EXE project.</li> | <li>Start Visual Basic 5.0 and create a new ActiveX EXE project.</li> | ||
<li>From the Project menu, selectProject properties and change the Project name to | <li>From the Project menu, selectProject properties and change the Project name to "Projtest."</li> | ||
<li>Add a Class Module and change its name to | <li>Add a Class Module and change its name to "Testclass."</li> | ||
<li><p>In Testclass' Code window, input following code:</p> | <li><p>In Testclass' Code window, input following code:</p> | ||
<pre class="codesample"> Public Event propchange(newv As String) | <pre class="codesample"> Public Event propchange(newv As String) | ||
Line 94: | Line 94: | ||
Public Sub showfrm() | Public Sub showfrm() | ||
MsgBox | MsgBox "asdfl" | ||
End Sub | End Sub | ||
Line 108: | Line 108: | ||
</pre></li> | </pre></li> | ||
<li>On the File menu, click | <li>On the File menu, click "Make ProjTest.exe."</li> | ||
<li>Copy the corresponding .exe, .tlb, and .vbr files to the client machine.</li> | <li>Copy the corresponding .exe, .tlb, and .vbr files to the client machine.</li> | ||
<li>Start the Automation Manager and the RemAuto Connection Manager to set necessary server-side configuration for using Projtest.testclass for Remote Automation.</li></ol> | <li>Start the Automation Manager and the RemAuto Connection Manager to set necessary server-side configuration for using Projtest.testclass for Remote Automation.</li></ol> | ||
Line 118: | Line 118: | ||
<li>Start the RemAuto Connection Manager to set necessary Client-side configuration for using Projtest.testclass.</li> | <li>Start the RemAuto Connection Manager to set necessary Client-side configuration for using Projtest.testclass.</li> | ||
<li>Launch Visual Basic 5.0 and create a new Standard EXE project with a standard form.</li> | <li>Launch Visual Basic 5.0 and create a new Standard EXE project with a standard form.</li> | ||
<li>From the Project menu, click References and select the | <li>From the Project menu, click References and select the "Projtest" box.</li> | ||
<li><p>In Form1's Code window, input following code:</p> | <li><p>In Form1's Code window, input following code:</p> | ||
<pre class="codesample"> Public WithEvents eventp As testclass | <pre class="codesample"> Public WithEvents eventp As testclass | ||
Line 130: | Line 130: | ||
a.showfrm | a.showfrm | ||
Set eventp = a | Set eventp = a | ||
a.testp = | a.testp = "test string" | ||
End Sub | End Sub | ||
Line 139: | Line 139: | ||
=== Result === | === Result === | ||
When the line | When the line "Set eventp = a" executes, you will get the following run- time error:<br /> | ||
<div class="errormessage"> | <div class="errormessage"> |
Latest revision as of 11:06, 21 July 2020
Article ID: 172312
Article Last Modified on 12/10/2003
APPLIES TO
- Microsoft Visual Basic 5.0 Control Creation Edition
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
This article was previously published under Q172312
SYMPTOMS
When attempting to raise a remote event across Remote Automation, the following run-time error appears:
CAUSE
Remote Automation does not currently support the use of WithEvents.
RESOLUTION
To support remote events with Visual Basic 5.0, use DCOM instead of Remote Automation. You can also use callbacks to simulate raising events remotely.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
Use the following steps on the server machine:
- Start Visual Basic 5.0 and create a new ActiveX EXE project.
- From the Project menu, selectProject properties and change the Project name to "Projtest."
- Add a Class Module and change its name to "Testclass."
In Testclass' Code window, input following code:
Public Event propchange(newv As String) Private propt As String Public Sub showfrm() MsgBox "asdfl" End Sub Public Property Get testp() As String testp = propt End Property Public Property Let testp(ByVal vNewValue As String) propt = vNewValue RaiseEvent propchange(propt) End Property
- On the File menu, click "Make ProjTest.exe."
- Copy the corresponding .exe, .tlb, and .vbr files to the client machine.
- Start the Automation Manager and the RemAuto Connection Manager to set necessary server-side configuration for using Projtest.testclass for Remote Automation.
Use the following steps on the client machine:
- Run Projtest.exe, which was copied from the Server side in the above steps.
- Start the RemAuto Connection Manager to set necessary Client-side configuration for using Projtest.testclass.
- Launch Visual Basic 5.0 and create a new Standard EXE project with a standard form.
- From the Project menu, click References and select the "Projtest" box.
In Form1's Code window, input following code:
Public WithEvents eventp As testclass Private Sub eventp_propchange(newv As String) MsgBox newv End Sub Private Sub Form_Load() Dim a As New testclass a.showfrm Set eventp = a a.testp = "test string" End Sub
- Run the project and check if the Remote Automation connection is correct, the message box should pop up on the server-side machine.
- Click OK to close the message box on the server-side machine.
Result
When the line "Set eventp = a" executes, you will get the following run- time error:
Expected behavior
A message box should appear on the client-side machine because the server raised the Propchange event.
NOTE: If both the client and the server are running on the same machine (with local automation), you will see the expected behavior.
Keywords: kbprb KB172312