Solved

Open Serial Open in VB.NET

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now