Hi
I'm using VB.NET 2005 trying to create a options form that lets you select the serial port to use I'm using:
to create a list of ports this works then usingHTML Code:Sub GetSerialPortNames() ' Show all available COM ports. For Each sp As String In My.Computer.Ports.SerialPortNames Serial_list.Items.Add(sp) Next End Sub
to open the port this also works. The problem being that when i try accessing serialport1 from the main form i get and error being Handles clause requires a WithEvents variable defined in the containing type or one of its base typesCode:Private Sub btnConnect_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnConnect.Click If SerialPort1.IsOpen Then SerialPort1.Close() End If Try With SerialPort1 .PortName = Serial_list.Text .BaudRate = 9600 .Parity = IO.Ports.Parity.None .DataBits = 8 .StopBits = IO.Ports.StopBits.One End With SerialPort1.Open() btnConnect.Enabled = False btnDisconnect.Enabled = True
The error is occuring at this line:
Thanks guys look forward to hearing from someone that knows more than meCode:Private Sub port_dataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles optionspage.SerialPort1.DataReceived- michael


- michael
Reply With Quote
