473,396 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 4116
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Todd | last post by:
Hello Oh ye Gods of .Net, I'm going to finally upgrade from VB(5) to NET. I havent written in much of anything else than Visual Basic. Will I need to buy Visual Studio or can I get by with...
3
by: Essam | last post by:
Hi All I have two programs ; both of them I need to give read/write access to the same Comm Port. How can I do so; using Code or third party tool/library
5
by: EMW | last post by:
Hi, For my windows application I'm using OpenNetCF's serialport stuff but I'm having a small problem. In my program I want to list a range of available ports to select. This works fine for the...
6
by: IanHale | last post by:
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...
4
by: Dave Cullen | last post by:
I need help using the serial port under VB.NET. I found a control called AxMSComm which I assume is the comm control, but there's no documentation in my MSDN help. Where can I find descriptions of...
2
by: Hugh Janus | last post by:
I am trying to receive GPS data into a pocket PC 5.0. I am using the device emulator. The main PC has a bluetooth dongle connected and is bonded with the bluetooth GPS transmitter to COM8. In...
5
by: =?Utf-8?B?UGV0ZXIgSm9uZXM=?= | last post by:
Hi, Hopefully this is a pretty basic question. I need to perform serial IO using VB.Net (VS2005/Framework 2.0) but the devices I communicate with can be either RS-232 or 422/485. Is this a...
4
by: JDS | last post by:
I have an application that interfaces with a USB device using the .Net serial port. The code works fine, displaying live data on the screen; that is until the USB lead is pulled out from the PC...
5
by: jen786 | last post by:
Hello every one , This is my first message on fourm ....looking forward to reply This is regarding serial port in visual basic 2008. when i run the following VB program. After 2 minutes it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.