473,379 Members | 1,386 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,379 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 4114
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.