Solved

Open Serial Open in VB.NET

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

932 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

15 Experts available now in Live!

Get 1:1 Help Now