# serial port comunication using visual basic

A

#### Anonymous

hi

we want to develope one project on communication between mobile and computer. i use serial port and data cable, i want to transfer my message from my pc to mobile but i don't know how to develop this project in vb6. so, please help me as soon as possible.

A

#### Anonymous

<p>Hi

<p>i want to pass a particular word on my form to be display as a label i have this code is there any way i can tell if the word is right, and been received by displaying the word. i can see the word lama. but no labe display on form
<pre>
Option Explicit

Dim Buffer As String
' Buffer to hold input string
Dim Instring As String
' Use COM1.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True

' Send the attention command to the modem.
MSComm1.Output = "lama " & vbCr ' Ensure that
' the modem responds with "OK".
' Wait for data to come back to the serial port.

Buffer$= Buffer$ & MSComm1.Input
If InStr(Buffer$, "Test") Then Label1.Caption = "OEM4 Detected" End If End Sub </pre> K #### kamal i am geting a 424 error while running something in the line "com1.CommPort = 2 'comm port no." is wrong. A #### Anonymous i am also trying for the same problem. If you have got the source code please send the below email id. thanks & regards [email protected] P #### Payal sheth Can u please tell me when will the Com1_OnComm event will fire ... well i m transmitting the data through com1.output but like how will i read the port... what i should write that the event com1_onComm fires S #### sahil Hi there! I did check your code on serial port in VB. Somehow it isn't working for me. Could you please resend me the code as i need it for my project. My email address is : [email protected] Thanks. S #### surya <p>Sir, <p>I am trying to write some data @ com1 and read the same data. Here is my sample code. But I could not send or receive and data. <p>What ever data I send is in txt_tx box and the receive data should be ib txt_rtx box. <pre> Private Sub cmdexit_Click() End End Sub Private Sub cmdtrigger_Click() Dim i, j As Integer i = MSComm1.OutBufferCount MsgBox i j = MSComm1.InBufferCount MsgBox j End Sub Private Sub Form_KeyPress(KeyAscii As Integer) MSComm1.SThreshold = 1 MSComm1.Output = KeyAscii txt_tx.Text = KeyAscii MSComm1.RThreshold = 1 End Sub Private Sub Form_Load() MSComm1.CommPort = 1 'Use com1 port MSComm1.Settings = "38400,N,8,1" 'Port Settings MSComm1.InputLen = 0 'Read entire Rx Buffer MSComm1.PortOpen = True 'open port End Sub Private Sub MSComm1_OnComm() If MSComm1.CommEvent = comEvReceive Then txt_rx.Text = MSComm1.Input Else MsgBox "Sorry No Data In Rx Buffer" End If End Sub </pre> T #### Thomas L. Burgin I have not been able to get the MScomm1 statement to work with VB .net What must be done to get it to work? Or better yet does someone have a solution to read text from a serial port using visual basic .net? Thomas A #### Anonymous <p>Hi, <p>The serial port takes in a binary number i.e 1010, I want VB to take the binary word and based on the number received, it will display an alert in a msgbox or a label. Could some help me with the code that lets the serial port input this data to VB and store it in some sort of variable. This is the code I have, and i am not sure if it is right. <pre> Private Sub Form_Load() frmVSS.Top = (Screen.Height - frmVSS.Height) / 2 frmVSS.Left = (Screen.Width - frmVSS.Width) / 2 com1.CommPort = 1 'comm port no. com1.Settings = "4800,N,8,1" 'Port Settings com1.RThreshold = 4 'no. of characters to receive com1.InputLen = 4 'no. of binary characters on which oncomm event fires com1.PortOpen = True 'open comm port End Sub </pre> <p>Any help is greatly appreciated. A #### Anonymous i want a code to send and receive sms from pc. M #### medo hi i wanna design a program that read data from serial port i create an infra-red circuit which can accept signal from any remote control and i tested it with downloaded programs and it works. so can anyone help me for design that program? thanks! A #### AtcKit Sir, i would like to know how to/what is the code in VB6, i want to create the interface that able to read and write the sms via serial port (between pc & mobile phone) using PDU format and ATcommands some sort like that.... Thank You. K #### Kenny Hi, i am currently working on a project dealing with the eyes of robot. I am currently struggling to use VB6 to enable the camera through the serial port to communicate with my robot. could you kindly please help me over here? thks! Kenny A #### Anonymous <p>hi, <p>i'm working on a project that transfer a text data between two computer and use the following code: <pre> Private Sub cmdExit_Click() End End Sub Private Sub cmdReceive_Click() If (Len(txtReceive) > 0) Then txtReceive = vbNullString txtReceive.Text = MSComm1.Input End Sub Private Sub cmdSend_Click() If (Len(txtSend) > 0) Then ' make sure that there is text to send If (MSComm1.PortOpen = True) Then ' make sure the serial port was initialized ' send the text as well as a carriage return and line feed appended to the end MSComm1.Output = txtSend & vbCr & vbLf Else MsgBox "ERROR: serial port not initialized" End If Else MsgBox "ERROR: there is no text to send" End If ' after sending clear the text out of the input box txtSend = vbNullString End Sub Private Sub cmdStart_Click() MSComm1.CommPort = 1 ' MSComm1.CommPort = 1 ' 9600 baud, no parity, 8 data, and 1 stop bit. MSComm1.Settings = "9600,N,8,1" ' Tell the control to read entire buffer when Input is used MSComm1.InputLen = 0 ' generate an event on every character received MSComm1.RThreshold = 1 ' Open the port. MSComm1.PortOpen = True ' Note: we should set the multiline property to True here in code but it is a read-only property ' do not allow the user to change the received text txtReceive.Locked = True ' clear the intial text boxes txtReceive.Text = vbNullString ' Send the attention command to the modem. InputData = "" End Sub Private Sub MSComm1_OnComm() Dim InputData As String Select Case MSComm1.CommEvent ' Errors Case comEventBreak ' A Break was received. MsgBox "Break received" Case comEventFrame ' Framing Error MsgBox "Framing error" Case comEventOverrun ' Data Lost. MsgBox "Overrun error" Case comEventRxOver ' Receive buffer overflow. MsgBox "Receive Buffer overflow" Case comEventRxParity ' Parity Error. MsgBox "Parity Error" Case comEventTxFull ' Transmit buffer full. MsgBox "Transmit Buffer full" Case comEventDCB ' Unexpected error retrieving DCB MsgBox "DCB error" ' Events Case comEvCD ' Change in the CD line. MsgBox "Carrier Detect changed state" Case comEvDSR ' Change in the DSR line. MsgBox "Data Set Ready (DSR) changed state" Case comEvRing ' Change in the Ring Indicator. MsgBox "Ring Indicator (RI) changed state" Case comEvReceive ' Received RThreshold # of characters ' MsgBox Str$(MSComm1.RThreshold) & " Characters received"
' While (MSComm1.InBufferCount > 0)
' only keep the last 5,000 characters -- throw away any characters older than that
' txtReceive = Right$(txtReceive, 5000) ' Wend InputData = InputData + MSComm1.Input Case comEvCTS ' Change in the CTS line. MsgBox "Clear To Send (CTS) changed state" ReceivedDataTextBox.Text = InputData InputData = "" Case comEvSend ' There are SThreshold number of characters in the transmit buffer MsgBox Str$(MSComm1.SThreshold) & " Characters remaining in transmit buffer"
Case comEvEOF ' An EOF charater was found in the input stream
End Select
End Sub
*****************************************
</pre>
<p>but i couldn't recieve any character.
Can any one help me in correcting this code.
if there is any contact me with the ff address.<br>
[email protected]

<p>thank you!

A

#### Anonymous

Hello there,

you can you a USB to RS232 converter.

M

#### Mariano Biltes

Is very easy to use this control. I uploaded a ie for u is in my site.

http://www.elbingo.8k.com

at end there is a link VBCOMM, click it and enjoy!!!!

A

#### Anonymous

I m having the same problem with u. At first i wrote my code in VB6, then I tried to convert it to VB.net (by using a new pc with only VB.net installed) but failed.

Any solution?

C

V

#### vijay sohra

why dont u use mscomm control. it has properties to do that. its a control with telephone pic on it
its available with all vb enterprise edition

2

#### 2c worth

If you are using VB .NET there is a free component you can use to send and receive SMS using a PC connected mobile phone. Follow the following link

http://www.emant.com/681002.page