473,785 Members | 2,482 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4139
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("core dll.dll")]

private static extern bool CloseHandle(Int Ptr hObject);

[DllImport("core dll.dll")]

private static extern bool WriteFile(IntPt r hFile, byte[] lpBuffer, Int32
nNumberOfBytesT oWrite, ref Int32 lpNumberOfBytes Written, IntPtr
lpOverlapped);

[DllImport("core dll.dll")]

private static extern bool ReadFile(IntPtr hFile, byte[] lpBuffer, Int32
nNumberOfBytesT oRead, ref Int32 lpNumberOfBytes Read, IntPtr lpOverlapped);
[DllImport("core dll.dll")]

private static extern IntPtr CreateFile( string lpFileName,

UInt32 dwDesiredAccess ,

UInt32 dwShareMode,

IntPtr lpSecurityAttri butes,

UInt32 dwCreationDispo sition,

UInt32 dwFlagsAndAttri butes,

IntPtr hTemplateFile);
"IanHale" <Ia*****@discus sions.microsoft .com> wrote in message
news:89******** *************** ***********@mic rosoft.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******** ********@TK2MSF TNGP10.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("core dll.dll")]

private static extern bool CloseHandle(Int Ptr hObject);

[DllImport("core dll.dll")]

private static extern bool WriteFile(IntPt r hFile, byte[] lpBuffer, Int32
nNumberOfBytesT oWrite, ref Int32 lpNumberOfBytes Written, IntPtr
lpOverlapped);

[DllImport("core dll.dll")]

private static extern bool ReadFile(IntPtr hFile, byte[] lpBuffer, Int32
nNumberOfBytesT oRead, ref Int32 lpNumberOfBytes Read, IntPtr lpOverlapped);
[DllImport("core dll.dll")]

private static extern IntPtr CreateFile( string lpFileName,

UInt32 dwDesiredAccess ,

UInt32 dwShareMode,

IntPtr lpSecurityAttri butes,

UInt32 dwCreationDispo sition,

UInt32 dwFlagsAndAttri butes,

IntPtr hTemplateFile);
"IanHale" <Ia*****@discus sions.microsoft .com> wrote in message
news:89******** *************** ***********@mic rosoft.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
1275
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 Visual Basic Standard for applications that send and recieve with the serial ports? I'm using a PC to talk to industrial equipment. thanks for reading,
3
3294
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
2703
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 first 16 ports, but not for the higher ports. I do this as folowed: For ab = 1 To 32
6
322
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 anything too complicated as all I want to do is read a serial stream of data. Thanks in advance
4
3380
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 the methods and properties of this control? And why doesn't MSDN have it? Thanks
2
2905
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 the device emulator, I am mapping Serial Port 1 to COM8. The below code *should* work as far as I can see but it does not. It hangs on the ReadLine line. Any ideas anyone? If I use hyperterminal on the main computer to read COM8 I can see the...
5
5624
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 concern to me as the programmer, i.e. does the UART or whatever handles the electrical side of things or do I need to be aware of the type of connection being made a program accordingly. I know I need to use System.IO.Ports.SerialPort but does this...
4
4779
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 when the program hangs. The obvious answer is not to pull the lead out, but unfortunately the application is one in which there is a high possibility the lead will be pulled out so the code needs to be more robust. The form has a timer...
5
4450
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 will will show on my hyperterminal (configured at 9600, 8bit,1 stop bit ). And I will get strange characters like }~j2 ....... Basically, i need help in reading and writing data in ( hex ) and display messages on hyperterminal: Code:
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10090
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.