Click here to Skip to main content
15,900,108 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: SEHException in vb.net2008 Pin
FgrAlomah8-Apr-10 7:31
FgrAlomah8-Apr-10 7:31 
GeneralRe: SEHException in vb.net2008 Pin
Luc Pattyn8-Apr-10 7:54
sitebuilderLuc Pattyn8-Apr-10 7:54 
GeneralRe: SEHException in vb.net2008 Pin
FgrAlomah8-Apr-10 8:06
FgrAlomah8-Apr-10 8:06 
GeneralRe: SEHException in vb.net2008 Pin
Luc Pattyn8-Apr-10 8:10
sitebuilderLuc Pattyn8-Apr-10 8:10 
QuestionError opening serial port that work before Pin
albchinsh7-Apr-10 22:31
albchinsh7-Apr-10 22:31 
AnswerRe: Error opening serial port that work before Pin
Steven J Jowett8-Apr-10 5:23
Steven J Jowett8-Apr-10 5:23 
GeneralRe: Error opening serial port that work before Pin
albchinsh8-Apr-10 5:51
albchinsh8-Apr-10 5:51 
GeneralRe: Error opening serial port that work before Pin
DaveAuld8-Apr-10 6:25
professionalDaveAuld8-Apr-10 6:25 
Still have the problem?

This is what i have used previously to communicate with Serial Ports;

Declarations;
VB.NET
Private WithEvents port As IO.Ports.SerialPort


Port Selection via ComboBox;
VB.NET
Private Sub LoadSerialPortNameList()
    'Clear existing list
    ComboBoxSerialPorts.Items.Clear()
    'Get the items
    For Each item As String In My.Computer.Ports.SerialPortNames
        ComboBoxSerialPorts.Items.Add(item)
    Next
End Sub


Port Connection via button;
'Check a port is selected
VB.NET
If ComboBoxSerialPorts.SelectedIndex < 0 Then
    'No port selected
    MsgBox("Select a serial port from the drop down list")
Else
    Try
        port = My.Computer.Ports.OpenSerialPort(ComboBoxSerialPorts.Items.Item(ComboBoxSerialPorts.SelectedIndex))
    Catch ex As Exception
        MsgBox("Error Opening Port: " + ex.Message)
    End Try
End If


Port Disconnection via button;
VB.NET
If port.IsOpen Then
               port.Close()
               Debug.WriteLine("Port Closed")
           Else
               MsgBox("Port is already closed.")
           End If


Notice the use of the My.Computer.Ports methods, don't know if that helps you any, but worked for me in the past no problem.

One of the biggest hassles was during dev/testing, if your app bombs, the OS seems to retain the lock on the port resource, leading to connection failures on subsequent runs, needing a reboot to release them.
Dave

Don't forget to rate messages!
Find Me On: Web|Facebook|Twitter|LinkedIn
Waving? dave.m.auld[at]googlewave.com


GeneralRe: Error opening serial port that work before Pin
albchinsh8-Apr-10 18:29
albchinsh8-Apr-10 18:29 
AnswerRe: Error opening serial port that work before Pin
Luc Pattyn8-Apr-10 20:07
sitebuilderLuc Pattyn8-Apr-10 20:07 
GeneralRe: Error opening serial port that work before Pin
albchinsh9-Apr-10 18:13
albchinsh9-Apr-10 18:13 
Questionvb.net DataView.RowFilter not working Pin
dodaddydo7-Apr-10 16:52
dodaddydo7-Apr-10 16:52 
AnswerRe: vb.net DataView.RowFilter not working Pin
Tej Aj7-Apr-10 19:45
Tej Aj7-Apr-10 19:45 
GeneralRe: vb.net DataView.RowFilter not working Pin
dodaddydo8-Apr-10 2:55
dodaddydo8-Apr-10 2:55 
AnswerRe: vb.net DataView.RowFilter not working Pin
Tej Aj7-Apr-10 20:08
Tej Aj7-Apr-10 20:08 
Questionprogress bar Pin
Daniel Engelkes6-Apr-10 17:03
Daniel Engelkes6-Apr-10 17:03 
AnswerRe: progress bar Pin
Anubhava Dimri6-Apr-10 19:45
Anubhava Dimri6-Apr-10 19:45 
AnswerRe: progress bar Pin
KreativeKai7-Apr-10 7:18
professionalKreativeKai7-Apr-10 7:18 
GeneralRe: progress bar Pin
Steven J Jowett7-Apr-10 22:54
Steven J Jowett7-Apr-10 22:54 
GeneralRe: progress bar Pin
KreativeKai9-Apr-10 6:05
professionalKreativeKai9-Apr-10 6:05 
AnswerRe: progress bar Pin
Gregory Gadow7-Apr-10 7:49
Gregory Gadow7-Apr-10 7:49 
Questionbecause it is being used by another process Pin
KreativeKai6-Apr-10 7:56
professionalKreativeKai6-Apr-10 7:56 
AnswerRe: because it is being used by another process Pin
Kschuler6-Apr-10 8:34
Kschuler6-Apr-10 8:34 
GeneralRe: because it is being used by another process Pin
KreativeKai6-Apr-10 9:21
professionalKreativeKai6-Apr-10 9:21 
AnswerRe: because it is being used by another process Pin
Gregory Gadow6-Apr-10 9:07
Gregory Gadow6-Apr-10 9:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.