Hi guys, I want to know how to use serial communication in VB. I saw a serial port icon in the component section. I want to know the api of the serial port. Hope anyone can teach me or any websites that teach this thx!
Printable View
Hi guys, I want to know how to use serial communication in VB. I saw a serial port icon in the component section. I want to know the api of the serial port. Hope anyone can teach me or any websites that teach this thx!
Download the 101 Samples for your version of VB.Net
Code:' This function attempts to open the passed Comm Port. If it is
' available, it returns True, else it returns False. To determine
' availability a Try-Catch block is used.
Private Function IsPortAvailable(ByVal ComPort As Integer) As Boolean
Try
CommPort.Open(ComPort, 115200, 8, RS232.DataParity.Parity_None, _
RS232.DataStopBit.StopBit_1, 4096)
' If it makes it to here, then the Comm Port is available.
CommPort.Close()
Return True
Catch
' If it gets here, then the attempt to open the Comm Port
' was unsuccessful.
Return False
End Try
End Function
what does it mean by download 101 sample? where to download?
This is what i wrote. Because the VB studio component have serial port, so ?I use it to do the serial communication. Like this correct to open the serial and write to the serial thanks!Code:SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.PortName = "COM1"
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.Open()
SerialPort1.RtsEnable = True
i = SerialPort1.CtsHolding
Label1.Text = "Successfully Connected!"
If (SerialPort1.RtsEnable) Then
SerialPort1.Write("1")
Label3.Text = i
SerialPort1.WriteLine("1")
End If
Label2.Text = SerialPort1.WriteBufferSize
'Label2.Text = SerialPort1.ReadByte
SerialPort1.Close()
Sure glad you asked this question I been goofing around with doing stuff like this too my question is how do you control the stream using a buffer?
Sample programs to help people understand how VS works.
http://msdn.microsoft.com/en-us/bb330936.aspx
see my (dbasnett) here http://www.vbforums.com/showthread.php?t=530790
Do you have the 2008 version?
ya I have 2008 version, oblio, I tried the program but it still doesnt work
Well, download the samples, and TRY some of them. Take our word for it that every one works.
Step thru it line by line (pressing F10) to see HOW it works.
The code that I posted was from the samples, and works.
It checks the COM ports, and sends AT to each to test for modem.