Solved

Open Serial Open in VB.NET

Posted on 2004-10-02
2
1,298 Views
Last Modified: 2007-12-19
Hi,

Can anybody tell me how to I write a code Open Serial COM Port in VB.NET? I have found a sample from http://www.codeworks.it/net/VBNetRs232.htm but I dont know how to add in into my project! Can provide me more information and example from others website?

Your help is highly appreciated!

Rgds,
cathy
0
Comment
Question by:kaifong78
2 Comments
 
LVL 1

Accepted Solution

by:
telefoniaip earned 125 total points
ID: 12213117
FOR OPEN PORT USING:

Dim MSCOM As AxMSCommLib.AxMSComm
  MSCOM._CommPort = 1
        MSCOM.Settings = "38400,N,8,1"
        MSCOM.InputLen = 0
         MSCOM.PortOpen = True
        MSCOM.Enabled = True
        Timer1.Enabled = True

For get data do you need put a TIMER:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Dim MSCOM As AxMSCommLib.AxMSComm
        Dim datA As Object = MSCOM.Input
        rt.Text = rt.Text & datA

IF you need get some data not all data:

     Dim MSCOM As AxMSCommLib.AxMSComm
        Dim datA As Object = MSCOM.Input
        rt.Text = rt.Text & datA

'''''' the next linea indicate if the data contain keywork Password add the result in a textbox.

        If InStr(datos, "Password:") > 0 Then
rt.Text = rt.Text & datA
                    End If

If you need send data:

 MSCOM.Output = "Hello How Are ?"
            MSCOM.Output = (vbCrLf)

comenary:
(vbCrLf) =  ENTER KEY.
             
0
 

Author Comment

by:kaifong78
ID: 12215019
Hi,

Thank you for your reply. However MSComm32.ocx is not delivered with Visual Studio, I am using VB.NET. Please take a look this URL  http://ourworld.compuserve.com/homepages/richard_grier/NETCommOCX.htm

Code is quite similar with MSCOMM

        AxNETComm1.CommPort = 1
        AxNETComm1.PortOpen = True
        AxNETComm1.RThreshold = 1
        AxNETComm1.set_Output("Hello" & vbCr)

I have sucess to sent text to our Making System via RS203 with this code.

MSCOM.Output = "Hello How Are ?"
            MSCOM.Output = (vbCrLf)

The output only display in frist line -> Hello How Are ?

Do you know how do I sent a 2nd text to 2nd line?

example output:
Hello How Are You? -> 1st line in system screen
I am fine.  -> 2nd line in system screen

I have tried WriteLine but got error! Please help. Thanks







0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question