Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Go Back  Xtreme Visual Basic Talk > > > Using MSCOMM control in code (not on a form)


Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2002, 06:21 AM
Asahara
Guest
 
Posts: n/a
Unhappy Using MSCOMM control in code (not on a form)


Hi everybody.

I am trying to make a class that uses a COM port. So I need to instantiate a MSCOMM control in code. I use the following code

Public WithEvents MyComm As MSComm


Private Sub Class_Initialize()
Set MyCOmm = CreateObject("MSComm")
.
.
.
End Sub

It drops with error "Active X component can't create object"

I also tried to declare the MyComm variable as MSCommLib.MsComm
and use the string "MSCommLib.MsComm"
in the CreateObject function. This code drops with error "Type Mismatch"

I have included the MSComm control in the Controls tab.

Can anybody help please ?

Thank you all for bothering with my little problem and happy coding.
Reply With Quote
  #2  
Old 11-06-2002, 11:07 AM
BillSoo's Avatar
BillSooUsing MSCOMM control in code (not on a form) BillSoo is offline
Code Meister

Retired Moderator
* Guru *
 
Join Date: Aug 2000
Location: Vancouver, BC, Canada
Posts: 10,441
Default

Have you set a *REFERENCE* to the mscomm.ocx? Do NOT add it to COMPONENTS.....
__________________
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Reply With Quote
  #3  
Old 11-08-2002, 09:19 AM
Asahara
Guest
 
Posts: n/a
Default

Quote:
Originally posted by BillSoo
Have you set a *REFERENCE* to the mscomm.ocx? Do NOT add it to COMPONENTS.....
Yes mate. That was it ! Thanks !
Reply With Quote
  #4  
Old 08-13-2003, 05:37 PM
turbo-d turbo-d is offline
Newcomer
 
Join Date: Aug 2003
Posts: 1
Default

Sorry, I'm a bit new to VB (and the world of Windows Programing). I want to do the exact same thing as Asahara. Can you tell me what you mean by:
"set a *REFERENCE* to the mscomm.ocx"
I know what a reference is in C, what is it in VB?

Thanks So Much.
Reply With Quote
  #5  
Old 08-14-2003, 04:38 AM
BillSoo's Avatar
BillSooUsing MSCOMM control in code (not on a form) BillSoo is offline
Code Meister

Retired Moderator
* Guru *
 
Join Date: Aug 2000
Location: Vancouver, BC, Canada
Posts: 10,441
Default

In VB6, under the Project menu, there are two similar items. One is "References..." and the other is "Components..."

When you add a reference to an ActiveX DLL, you are then able to create instances of the objects contained in that DLL.

ActiveX controls (OCX) can be added as components. When you add them, the controls contained in the OCX file appear in the toolbox. You can then put them on the form.

The MSCOMM32.OCX file contains the mscomm control component. Normally, you add it as a component. The mscomm icon (a phone) appears in the toolbox and you add it to a form.

However, an OCX is simply a special form of a DLL. As such, it's possible to add a REFERENCE to MSCOMM32.OCX instead of treating it as a COMPONENT. This means that you can create instances of the mscomm control at runtime WITHOUT having to put them on a form.

*WARNING* - Using the mscomm control this way is somewhat nonstandard. As such, once you compile the program and create an installable version (using, say, INNO Setup), it will not correctly maintain the proper licence info. This means that your program will work IF the target machine has an existing, licenced copy of mscomm32.ocx but installing to a clean machine will fail to provide the proper licence. If you only use this technique on your own system, no worries.
__________________
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form) Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
 
Using MSCOMM control in code (not on a form)
Using MSCOMM control in code (not on a form)
 
-->