Dockable Container - General VB Question

Dockable Container - General VB Question

Anonymous
Not applicable
172 Views
4 Replies
Message 1 of 5

Dockable Container - General VB Question

Anonymous
Not applicable
I am working with the Dockable Container in AutoCAD 2000. I am creating a
custom OCX in VB, which is getting displayed in the Dockable Container. My
question is more VB in nature, but hopefully someone can help. In VB, I am
creating an OCX which contains a standard module, a user control, and a
form. In the user control, I am reference MSCOMM32 to communicate with the
COM-PORT, but I am declaring it as Public WithEvents so that it will respond
to events; therefore, I can't use it in a standard module. My form is setup
to change the COM-PORT settings. My problem is that I can't "reference" my
MSCOMM32 object from my form. How can you call procedures or reference
variables/objects in other class modules than can not be put into a standard
module?? Thanks for any help.
0 Likes
173 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Could you please rephrase the question? I see no reason why you can't
instantiate your control on your UserForm, it functions just like a regular
form.

"Bill Major" wrote in message
news:85cpc7$jt11@adesknews2.autodesk.com...
> I am working with the Dockable Container in AutoCAD 2000. I am creating a
> custom OCX in VB, which is getting displayed in the Dockable Container.
My
> question is more VB in nature, but hopefully someone can help. In VB, I
am
> creating an OCX which contains a standard module, a user control, and a
> form. In the user control, I am reference MSCOMM32 to communicate with
the
> COM-PORT, but I am declaring it as Public WithEvents so that it will
respond
> to events; therefore, I can't use it in a standard module. My form is
setup
> to change the COM-PORT settings. My problem is that I can't "reference"
my
> MSCOMM32 object from my form. How can you call procedures or reference
> variables/objects in other class modules than can not be put into a
standard
> module?? Thanks for any help.
>
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
While it is true that you cannot declare an object WithEvents in a standard
module, there is nothing preventing you from accessing that object's methods
and properties from anywhere in your project so long as it public. Simply
preface the name of the object with the name of its containing form:
myControl.Update becomes myForm.myControl.Update.

P.S. Out of curiousity, why would you change COM port settings from AutoCAD?

"Bill Major" wrote in message
news:85crnr$js7@adesknews2.autodesk.com...
> My VB project consists of a User Control (which ends up being displayed in
> the Dockable Container in AutoCAD), a standard module, and a UserForm. My
> User Control has various buttons, etc. that interact with AutoCAD. The
User
> Control contains code that references, creates, and sets a MSCOMM32 object
> to communicate with the COM-PORT. That's the easy part.
>
> I also have a User Form that I want to popup so that the user can change
the
> COM-PORT settings if necessary. However, I cannot access the MSCOMM32
> object that I created in the User Control. I can not place the MSCOMM32
> object in a standard module for global access because I declare my ojbect
as
> follows:
>
> Public WithEvents theCommPort As MSCommLib.MSComm
>
> When using WithEvents so an object will respond to events, it must be
placed
> in a class module, such as a Form. My question is how can I access
> 'theCommPort' from other Forms or User Controls? Can anyone suggest a
> better method of using MSCOMM32? Using it this way is event driven.
There
> is also a polling method technique of using MSCOMM32, but have not
explored
> it.
0 Likes
Message 4 of 5

Anonymous
Not applicable
My VB project consists of a User Control (which ends up being displayed in
the Dockable Container in AutoCAD), a standard module, and a UserForm. My
User Control has various buttons, etc. that interact with AutoCAD. The User
Control contains code that references, creates, and sets a MSCOMM32 object
to communicate with the COM-PORT. That's the easy part.

I also have a User Form that I want to popup so that the user can change the
COM-PORT settings if necessary. However, I cannot access the MSCOMM32
object that I created in the User Control. I can not place the MSCOMM32
object in a standard module for global access because I declare my ojbect as
follows:

Public WithEvents theCommPort As MSCommLib.MSComm

When using WithEvents so an object will respond to events, it must be placed
in a class module, such as a Form. My question is how can I access
'theCommPort' from other Forms or User Controls? Can anyone suggest a
better method of using MSCOMM32? Using it this way is event driven. There
is also a polling method technique of using MSCOMM32, but have not explored
it.
0 Likes
Message 5 of 5

Anonymous
Not applicable
Only forms and class modules allow variables to be dim'ed "WithEvents."

"Bill Major" wrote in message
news:85cpc7$jt11@adesknews2.autodesk.com...
> I am working with the Dockable Container in AutoCAD 2000. I am creating a
> custom OCX in VB, which is getting displayed in the Dockable Container.
My
> question is more VB in nature, but hopefully someone can help. In VB, I
am
> creating an OCX which contains a standard module, a user control, and a
> form. In the user control, I am reference MSCOMM32 to communicate with
the
> COM-PORT, but I am declaring it as Public WithEvents so that it will
respond
> to events; therefore, I can't use it in a standard module. My form is
setup
> to change the COM-PORT settings. My problem is that I can't "reference"
my
> MSCOMM32 object from my form. How can you call procedures or reference
> variables/objects in other class modules than can not be put into a
standard
> module?? Thanks for any help.
>
>
0 Likes