473,325 Members | 2,805 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,325 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 4110
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.