VECCHIO CODICE IN VB6

    Private Sub Form_Load()
    MSComm1.CommPort = 8
    MSComm1.Settings = 9600,n,8,1?
    MSComm1.RThreshold = 1
    MSComm1.PortOpen = True
    End Sub

    Private Sub MSComm1_OnComm()
    Dim Rx$
    Rx$ = MSComm1.Input
    If Len(Rx$) > 9 Then
    Text2.text = 
    Text2.text = Text2.text & Rx$
    If Rx$ = 0415151A74? Then
    WindowsMediaPlayer1.URL = C:\eduglow\suoni\asciugacapelli.wav
    schermo.Picture = LoadPicture(C:\eduglow\figure\asciugacapelli.jpg)
    Call WindowsMediaPlayer1.Controls.Play

    End If
    End sub


NUOVO CODICE IN VB.NET

        Public Class Form1
        Dim Rx As String = 
        Public Event DataReceived As IO.Ports.SerialDataReceivedEventHandler
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.PortName = COM1?
        SerialPort1.BaudRate = 9600
        SerialPort1.Parity = IO.Ports.Parity.None
        SerialPort1.DataBits = 8
        SerialPort1.StopBits = IO.Ports.StopBits.One
        SerialPort1.Handshake = IO.Ports.Handshake.None
        SerialPort1.RtsEnable = True
        SerialPort1.Open()
        If SerialPort1.IsOpen = True Then
            SerialPort1.Write(MicroCommand)
        End If
        End Sub
        Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Rx = SerialPort1.ReadExisting or SerialPort1.ReadLine
        Me.Invoke(New EventHandler(AddressOf DoUpdate))
        End Sub
        Public Sub DoUpdate()
        If Len(Rx) > 9 Then
        TextBox2.Text = 
        TextBox2.Text = TextBox2.Text & Rx
        If Rx = 0415151A74? Then
        WindowsMediaPlayer1.URL = C:\eduglow\suoni\asciugacapelli.wav
        PictureBox1.Image = Image.FromFile(C:\eduglow\figure\asciugacapelli.jpg)
        WindowsMediaPlayer1.Controls.Play()
        End If
        End If
        End Sub
        End Class