471,339 Members | 1,268 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,339 software developers and data experts.

Use of serial port in Visual Basic .NET

Is there any way of simply using the COM port from Visual Basic? All the
solutions I've found seem to require the use of Visual Studio whereas I only
have the the 'basic' version. I'm not after anything too complicated as all I
want to do is read a serial stream of data.

Thanks in advance
Jul 21 '05 #1
6 3999
IanHale,

You can use it, just look in the newsgroups on Dick Grier

http://groups-beta.google.com/groups...=Search+Groups

I hope this helps

Cor
Jul 21 '05 #2
Thanks Cor

Sorry if I'm being a bit slow - but the search turned up many entries - none
of which seemed to answer simple question - do you know of any simple guide
on getting going. I even tried looking up Dick's book on Amazon - but they
claim a 6-8 week delivery (if at all!)

"Cor Ligthert" wrote:
IanHale,

You can use it, just look in the newsgroups on Dick Grier

http://groups-beta.google.com/groups...=Search+Groups

I hope this helps

Cor

Jul 21 '05 #3
p/invoke the win32 CreateFile, WriteFile, ReadFile, CloseHandle from
coredll.dll (see below). Call CreateFile with "COM1:" for eample and hey
presto you have an IntPtr to an open com port. From there use this handle
with the other stuff.

You might wanna create a class to wrap all this stuff to make it more OO and
to implement IDisposable on it.

[DllImport("coredll.dll")]

private static extern bool CloseHandle(IntPtr hObject);

[DllImport("coredll.dll")]

private static extern bool WriteFile(IntPtr hFile, byte[] lpBuffer, Int32
nNumberOfBytesToWrite, ref Int32 lpNumberOfBytesWritten, IntPtr
lpOverlapped);

[DllImport("coredll.dll")]

private static extern bool ReadFile(IntPtr hFile, byte[] lpBuffer, Int32
nNumberOfBytesToRead, ref Int32 lpNumberOfBytesRead, IntPtr lpOverlapped);
[DllImport("coredll.dll")]

private static extern IntPtr CreateFile( string lpFileName,

UInt32 dwDesiredAccess,

UInt32 dwShareMode,

IntPtr lpSecurityAttributes,

UInt32 dwCreationDisposition,

UInt32 dwFlagsAndAttributes,

IntPtr hTemplateFile);
"IanHale" <Ia*****@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Thanks Cor

Sorry if I'm being a bit slow - but the search turned up many entries -
none
of which seemed to answer simple question - do you know of any simple
guide
on getting going. I even tried looking up Dick's book on Amazon - but they
claim a 6-8 week delivery (if at all!)

"Cor Ligthert" wrote:
IanHale,

You can use it, just look in the newsgroups on Dick Grier

http://groups-beta.google.com/groups...=Search+Groups

I hope this helps

Cor

Jul 21 '05 #4
don't know the syntax for pinvoking in VB

"Stelrad Doulton" <___@____.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
p/invoke the win32 CreateFile, WriteFile, ReadFile, CloseHandle from
coredll.dll (see below). Call CreateFile with "COM1:" for eample and hey
presto you have an IntPtr to an open com port. From there use this handle
with the other stuff.

You might wanna create a class to wrap all this stuff to make it more OO
and to implement IDisposable on it.

[DllImport("coredll.dll")]

private static extern bool CloseHandle(IntPtr hObject);

[DllImport("coredll.dll")]

private static extern bool WriteFile(IntPtr hFile, byte[] lpBuffer, Int32
nNumberOfBytesToWrite, ref Int32 lpNumberOfBytesWritten, IntPtr
lpOverlapped);

[DllImport("coredll.dll")]

private static extern bool ReadFile(IntPtr hFile, byte[] lpBuffer, Int32
nNumberOfBytesToRead, ref Int32 lpNumberOfBytesRead, IntPtr lpOverlapped);
[DllImport("coredll.dll")]

private static extern IntPtr CreateFile( string lpFileName,

UInt32 dwDesiredAccess,

UInt32 dwShareMode,

IntPtr lpSecurityAttributes,

UInt32 dwCreationDisposition,

UInt32 dwFlagsAndAttributes,

IntPtr hTemplateFile);
"IanHale" <Ia*****@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Thanks Cor

Sorry if I'm being a bit slow - but the search turned up many entries -
none
of which seemed to answer simple question - do you know of any simple
guide
on getting going. I even tried looking up Dick's book on Amazon - but
they
claim a 6-8 week delivery (if at all!)

"Cor Ligthert" wrote:
IanHale,

You can use it, just look in the newsgroups on Dick Grier

http://groups-beta.google.com/groups...=Search+Groups

I hope this helps

Cor


Jul 21 '05 #5
Ian,

The most unliked part of computing for me, however this should do it for
you.

http://msdn.microsoft.com/msdnmag/is...netserialcomm/

I hope this helps,

Cor
Jul 21 '05 #6
Thanks Cor - I'll give it a go. The words 'where angels fear to tread....'
spring to mind!

"Cor Ligthert" wrote:
Ian,

The most unliked part of computing for me, however this should do it for
you.

http://msdn.microsoft.com/msdnmag/is...netserialcomm/

I hope this helps,

Cor

Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Todd | last post: by
3 posts views Thread by Essam | last post: by
5 posts views Thread by EMW | last post: by
6 posts views Thread by IanHale | last post: by
4 posts views Thread by Dave Cullen | last post: by
2 posts views Thread by Hugh Janus | last post: by
5 posts views Thread by =?Utf-8?B?UGV0ZXIgSm9uZXM=?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.