Sub btnopen_MouseClicked (EventData As MouseEvent)
If btnopen.Text = "Open" Then
sp.Open(cmbport.Value)
sp.SetParams (BaudRate , DataBits , StopBits , Parity )
sp.PurgePort(8)
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
btnopen.text = "Close"
lblstatus.Text = "Status: Connected"
Else
AStream_Terminated
End If
End Sub