Meo's Web site
     

http://www.meo-x.net/home.php

     Home | Information | Know-how | Sections | Documents | Services | Plus |      Blog |
 

 

 

 

 

Links / Liens:

Free C# Compilers and Interpreters

 

 

C#:

Didier Meo: Interface en C#

 

 

Downloads:

a small Meo's WPF demo about Data binding with Master-Detail and MS Access dataset in a zip file enclosed MEOReferences.exe and MEOReferences.mdb
a small Meo's demo project about Databinding in ASP.Net 4.0 with C#, LinQ to SQL and SQL Server 2008, in the file MEO_Test.zip
a small Meo's Silverlight 4.0 demo project in the file MEO_SilverlightTest.zip

 

VB.Net 2015: text transmission through a COM port

VB.Net 2015 text transmission through a COM port

by Didier MEO, IT Consultant. 13/12/2015. e-mail: didiermeo@gmail.com

Description

 VB.Net 2015: text transmission through a COM port. .

 VB.Net 2015: transmission des textes à travers une port COM.

 VB.Net 2015: Textübertragung durch irgendeinen COM-Port.

download (zip format)


                          ' ein kleines Tool in VB.Net unter Visual Studio 2015 zwecks Text�bertragung durch irgendeinen COM-Port
'
'
'
'
'
' Datei:  frmMEOCOMdatatrans.vb
Public Class frmMEOCOMdatatrans
    Private Sub btnTransmission_Click(sender As Object, e As EventArgs) Handles btnTransmission.Click
        Dim strCOMdata, strPortNr As String
        strCOMdata = txtContent.Text
        strPortNr = txtPort.Text
        txtMessage.Text = ""
        Dim objCOMdata As New COMdata
        objCOMdata.SendCOMdata(strCOMdata, strPortNr)
        txtMessage.Text = objCOMdata.Message
    End Sub
    Private Sub btnReception_Click(sender As Object, e As EventArgs) Handles btnReception.Click
        Dim strPortNr As String
        strPortNr = txtPort.Text
        txtMessage.Text = ""
        Dim objCOMdata As New COMdata
        txtContent.Text = objCOMdata.ReceiveCOMdatafromPortNr(strPortNr)
        txtMessage.Text = objCOMdata.Message
    End Sub
    Private Sub btnErase_Click(sender As Object, e As EventArgs) Handles btnErase.Click
        txtMessage.Text = ""
    End Sub
    Private Sub txtPort_Leave(sender As Object, e As EventArgs) Handles txtPort.Leave
        txtMessage.Text = ""
    End Sub
End Class
'-----------------------------------------------------------------------------------------------------------------------------------
' Datei: COMdata.vb
Public Class COMdata
    Private strMessage As String
    Public ReadOnly Property Message As String
        Get
            Return strMessage
        End Get
    End Property
    ' Send strings to a serial port, p.ex. strPortNr = "COM6"
    Public Sub SendCOMdata(ByVal strCOMdata As String, ByVal strPortNr As String)
        Try
            Using comNr As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(strPortNr)
                comNr.WriteLine(strCOMdata)
            End Using
        Catch ex As Exception
            strMessage = ex.Message
        End Try
    End Sub
    ' Receive strings from a serial port, p.ex. strPortNr = "COM6" 
    Public Function ReceiveCOMdatafromPortNr(ByVal strPortNr As String) As String
        Dim strReceiveCOMdata As String = ""
        Dim comNr As IO.Ports.SerialPort = Nothing
        strMessage = ""
        Try
            Try
                comNr = My.Computer.Ports.OpenSerialPort(strPortNr)
                comNr.ReadTimeout = 10000
            Catch ex As Exception
                strMessage = ex.Message
                Return strReceiveCOMdata
            End Try
            Do
                Dim COMdata As String = comNr.ReadLine()
                If COMdata Is Nothing Then
                    Exit Do
                Else
                    strReceiveCOMdata &= COMdata & vbCrLf
                End If
            Loop
        Catch ex As TimeoutException
            strMessage = "Error: Serial Port " & strPortNr & " read timed out."
            strReceiveCOMdata = Nothing
        Finally
            If comNr IsNot Nothing Then comNr.Close()
        End Try
        Return strReceiveCOMdata
    End Function
End Class


         


' Datei: Application.Designer.vb
'------------------------------------------------------------------------------
' 
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.42000
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' 
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
    'NOTE: This file is auto-generated; do not modify it directly.  To make changes,
    ' or if you encounter build errors in this file, go to the Project Designer
    ' (go to Project Properties or double-click the My Project node in
    ' Solution Explorer), and make changes on the Application tab.
    '
    Partial Friend Class MyApplication
 _
        Public Sub New()
            MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
            Me.IsSingleInstance = false
            Me.EnableVisualStyles = true
            Me.SaveMySettingsOnExit = true
            Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
        End Sub
 _
        Protected Overrides Sub OnCreateMainForm()
            Me.MainForm = Global.MEOIDdatatrans.frmMEOCOMdatatrans
        End Sub
    End Class
End Namespace
         
 
 
 
 
Didier Meo's ASP.NET web site  

 

 

Copyright © http://www.meo-x.net/home.php. ALL RIGHTS RESERVED