By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,384 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,384 IT Pros & Developers. It's quick & easy.

MSComm control in VB.NET

P: n/a
I am using an activex control mscomm to control a serial
port in VB.NET. I place the control on the main form and
set its port, baud rate, etc. properties. After creating
a code module that needs to access the serial port, I
cannot seem to be able to access the mscomm control from
within a code module. In VB6 you could use the statement
frmMain.Mscomm1.output = "some data string" in the code
module but this won't work in VB.NET. Does anyone know
the correct syntax to send data to an mscomm activex
control located on a form from a code module?
Thanks for any help,
Barry

Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
* "Barry Martin" <bm*******@att.net> scripsit:
I am using an activex control mscomm to control a serial
port in VB.NET. I place the control on the main form and
set its port, baud rate, etc. properties. After creating
a code module that needs to access the serial port, I
cannot seem to be able to access the mscomm control from
within a code module. In VB6 you could use the statement
frmMain.Mscomm1.output = "some data string" in the code
module but this won't work in VB.NET. Does anyone know
the correct syntax to send data to an mscomm activex
control located on a form from a code module?


You need a reference to the control. Default instances of forms are
gone, that's why the code won't work. You will have to pass a reference
to the control to the module, for example in a public property of the
module or the parameter of a method defined in the module.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
Default instances will be back in the next version of VB.NET.
Not sure whether I really like that or not yet.

-Rob Teixeira [MVP]

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
* "Barry Martin" <bm*******@att.net> scripsit:
I am using an activex control mscomm to control a serial
port in VB.NET. I place the control on the main form and
set its port, baud rate, etc. properties. After creating
a code module that needs to access the serial port, I
cannot seem to be able to access the mscomm control from
within a code module. In VB6 you could use the statement
frmMain.Mscomm1.output = "some data string" in the code
module but this won't work in VB.NET. Does anyone know
the correct syntax to send data to an mscomm activex
control located on a form from a code module?


You need a reference to the control. Default instances of forms are
gone, that's why the code won't work. You will have to pass a reference
to the control to the module, for example in a public property of the
module or the parameter of a method defined in the module.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3

P: n/a
* "Rob Teixeira [MVP]" <RobTeixeira@@msn.com> scripsit:
Default instances will be back in the next version of VB.NET.
Not sure whether I really like that or not yet.


I am very happy about that... but it should be an "optional" feature.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
Hi,

This works fine. Just add the control to the Toolbox (use browse from
Customize Toolbox/COM components. Then, drop MSComm on your form. The IDE
will then create the wrapper DLLs that are required. After than, using
MSComm is quite like its use under VB6.

I have examples in my book, if you are interested (see below).

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
Nov 20 '05 #5

P: n/a
I certainly do agree with that.

-Rob Teixeira [MVP]

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
* "Rob Teixeira [MVP]" <RobTeixeira@@msn.com> scripsit:
Default instances will be back in the next version of VB.NET.
Not sure whether I really like that or not yet.


I am very happy about that... but it should be an "optional" feature.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #6

P: n/a
Hi Dick,
Thanks for the detailed info. I will definitely check out
your book.
Thanks again
Barry
-----Original Message-----
Hi,

This works fine. Just add the control to the Toolbox (use browse fromCustomize Toolbox/COM components. Then, drop MSComm on your form. The IDEwill then create the wrapper DLLs that are required. After than, usingMSComm is quite like its use under VB6.

I have examples in my book, if you are interested (see below).
Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rdEdition ISBN 1-890422-27-4 (391 pages) published February 2002.

.

Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.