Results 1 to 2 of 2

Thread: Using MSComm control

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Posts
    8

    Using MSComm control

    Hello!

    I am trying to write a program that communicates with a device through Com port 2. I found a VB6 program that communicates with it fine ... but after using the same methods in .NET I couldn't get it to work. It looks like the OnComm event is never even triggered ... I wrote a really simple class to send a command to the device and then display a message that lets me know the OnComm event has been activated ... I'm not getting any response. Can anyone help?

    Here's the little test program I wrote:

    Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Instring As String

    Comm2.CommPort = 2

    Comm2.Settings = "9600,N,8,1"

    Comm2.InputLen = 0

    If Comm2.PortOpen = False Then
    Comm2.PortOpen = True

    End If
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Comm2.Output = "SVAA" & Chr(13)

    End Sub


    Private Sub Comm2_OnComm(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Comm2.OnComm

    Select Case Comm2.CommEvent
    Case MSCommLib.OnCommConstants.comEvReceive
    Dim Buffer As VariantType
    Buffer = Comm2.Input

    Label1.Text = "On Comm Active"

    End Select

    End Sub

    End Class

  2. #2
    Lively Member
    Join Date
    Sep 2002
    Posts
    77
    In answer to your other quiry I suggested that you use a timer to read the comm port into a string. you can manage the string from there. I have never tried the oncomm event but using the timer to read the input buffer into a string works fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width