?
Solved

Referencing an MSComm Control from a Class

Posted on 2002-05-03
1
Medium Priority
?
291 Views
Last Modified: 2007-12-19
I have a class (CDevice) that should reference an MSComm Control (MSComm1) on a Form (Form1). The class has a public property (Device). In the Class it is declared as:

  Private mvarDevice As MSComm

The class has the public property Set/Get methods for mvarDevice.

In Form1, I have the declaration:

  Private WithEvents ODevice As CDevice.

In the Form_Load event, I have the statement:

  Set ODevice = New CDevice

In CDevice Class Initialize event, I have the statement:

  Set mvarDevice = Form1.MSComm1

My problem is I get an error in the above statement. VB reports an error indicating the events for MSComm1 do not match... something. I'll post the actual error message.

What could be the problem. At the moment I am not using the mvarDevice reference to reference MSComm1 on Form1 because of this error. I am using Form1.MSComm1... in the class to reference the MSComm Control.
0
Comment
Question by:bmatumbura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 total points
ID: 6988160
I have just created the following example to test this and it works fine:

Class module:

Private WithEvents mvarDevice As MSCommLib.MSComm

Public Event Test()

Public Property Set Device(ByRef DVC As MSCommLib.MSComm)
    Set mvarDevice = DVC
End Property

Private Sub Class_Initialize()
    Set Device = Form1.MSComm1
End Sub


Form Code:
Private WithEvents ODevice As CDevice
Private Sub Form_Load()
    Set ODevice = New CDevice
'    Set ODevice.Device = MSComm1
End Sub

Actually it is better to use the set odevice line in the form load event as shown here than in the class_initialise as this class could in theory be used with a project that does not have a "form1" form.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question