Solved

Open Serial Open in VB.NET

Posted on 2004-10-02
2
1,274 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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