i want to perform serial communication on selecting
.Net Framework2.0--->Visual Basic--->Device application
presently i am using this code
- Imports System.IO.Ports
-
Imports System.IO.Ports.Serialport
-
-
If Button1.Text Is "open port" then
-
SerialPort1.Open()
-
Button1.Text="close port"
-
Button2.Enabled=True
-
-
Else If Button1.Text Is "close port" then
-
SerialPort1.Close()
-
Button1.Text="open port"
-
Button2.Enabled=False
-
End If
-
-
//Inside button2 i am writing this code
-
SerialPort1.WriteLine(Textbox1.Text)
-
Listbox1.Items.Add("sent:" +TextBox1.Text)
-
-
//Inside serialport's property in DataReceived,i hav written this statement
-
ListBox1.Items.Add("Received" +Serialport1.ReadLine())
but i am getting error as
"An unhandled exception of type System.InvalidOperationException occurred in System.dll
Additional Information: The basestream is only available when the port is open "
so plz anyone help me in this issue ...
Thanking U in advance.....
expecting ur valuable results earlier.....
Regards
Indu