advertisement
from the Automation List department...
serial port comunication using visual basic
Communications systems and equipment. topic
Posted by prem on 19 July, 2004 - 10:12 am
hi there hope someone can help me here..!!!

im doing a new project involving two serial ports of the computer. firstly, i have interfaced the 1st serial port to a 8051 microcontroller to get data from the microcontroller.

the second serial port is connected to a nokia 30 gsm connectivity terminal (it can be a gsm modem or a gsm phone).

My question here is how can i use visual basic codes to read input from the 1st serial port (which is the microcontroller) and when there is a specific input, this visual basic should send data (in this case a sms ) to the gsm phone through the 2nd serial port. This sms should be sent automatically when there is an input from the 1st serial port.

please if anyone can help me, send me the codes or any information.

your help is much appreciated..!!!

thanks
my mail add: scorpioboy_19@hotmail.com


Posted by TK on 20 July, 2004 - 7:12 pm

The easiest way to access COM ports in Visual Basic 6 is by placing the Microsoft Comm control on a form, and writing code to read and write each serial port. There are plenty of examples on the web of using the Microsoft Comm control to send and recieve data from a serial port. You will need one Microsoft Comm control on your form per serial ports you wish to use.

Example of an infinite loop that takes data from one port and echos it onto another -


Dim sInput as String
While (True)
DoEvents
sInput = MSComm1.Input
If (Len(sInput) > 0) Then
MSComm2.Output = sInput
End If
Wend


Posted by Mariano Biltes on 24 October, 2005 - 11:02 pm
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!!!!


Posted by Manjula on 28 February, 2006 - 11:28 pm
Hello!

I am using Atmel 8051 in our project. Please give me information regarding how to download visual basic hex file into the 8051 memory. Give the information regarding suitable cross compiler with respect to this requirement.

Thanks and regards,

Manjula


Posted by Uzi on 12 March, 2006 - 8:08 pm
Hi,
I am working on a project which inputs 3 different measurements to a PC using RS232. I am new to VB 6. A PIC18F microcontroller is sending these 3 values to the PC, the VB program is supposed to display them on a simple stand alone program. I dont know much about programming in VB. I did research online but was unable to find a sample code meeting my design specifications. Are there any resources, sample code or suggestions for attacking this problem.
Thank you.


Posted by Hrqls on 6 May, 2006 - 12:34 am
have a look at
http://programmers-corner.com/sourcecode/111?PHPSESSID=661cd95b75a0 265fbe84cbdc9ef60553


Posted by eizzy on 16 June, 2006 - 6:48 pm
hi...

i also need your help. right now i developing a payment terminal program and the the terminal can send data via modem and another modem at the server receive the data... how i capture the data from the teminal and the modem at the server is using serial port communication...

pls. i need u guys help.


Posted by Brian E Boothe on 2 July, 2006 - 8:14 pm
why is it that alot of these industrial control guys have no clue what a search engine is,, geesh

These productive microcontroller tools were developed by Hanover Software

BXC-51 BASIC 8051 Cross-Compiler <bxc51.html> - the BASIC-52
Compiler of choice

BEC-51 BASIC 8051 Cross-Compiler <bec51.html> - the Blue Earth
BASIC Compiler of choice

BXC-51 Library Toolkit <bxc51lt.html> - the BASIC/Assembly
programmers toolkit

BXC-51 IDE <bxc51ide.html> - the BXC-51 programmer's integrated
development environment (IDE)

BXC-51 Simulator <bxcsim.html> - the BXC-51 programmer's
simulation tool

QComm <qcomm.html> - the communications scripting tool

Infinitor <inf.html> - the programmer's editor

SXA-51 8051 Cross-Assembler <sxa51.html> - 8051 Cross-Assembler

BXA-51 8051 Cross-Assembler <bxa51.html> - 8051 Cross-Assembler


Posted by Rachna Nambiar on 12 May, 2006 - 12:56 am
Hi,

Even I have the same problem. Completely new to Visual Basic. I have to get data form the serial port, and display it along with the time at which it was received. Can anyone send me a code how to do this. the data will be 2 Ascii characters at a time.

I would be very grateful if i could get this code.. its very very urgent.

Email address is rachna.nambiar@gmail.com


Posted by pradeep on 29 June, 2006 - 12:19 am
Hello!

I have an idea, but dont know whether it will workout or not. just try to send vb codes as strings in C code then generate hex code.. try out if it works pls let me also know...


Posted by batu_industry on 2 February, 2007 - 12:43 am
Hello!

If you have problem with Atmel 8051, I'll help you
make some program or use Visual Basic.

Send your question to: batu_industry @ yahoo. com


Posted by Sudheer on 2 August, 2007 - 12:05 am
Hello manjula,

I was also in search of that, here's what I can suggest.

One method is to use get a ready made program burner from the market. Second is to construct a programmer of your own. You will get nice, simple circuits at the following link:

http://www.kmitl.ac.th/~kswichit%20/easy2/easy2.htm

Bye,
newslettersforsudhi@yahoo.com


Posted by Sushma on 22 May, 2012 - 1:31 am
this code does not work even after the MSComm settings are done

> The easiest way to access COM ports in Visual Basic 6 is by placing the
> Microsoft Comm control on a form, and writing code to read and write each serial port.
---- snip ----

> Example of an infinite loop that takes data from one port and echos it onto another -

> Dim sInput as String
> While (True)
> DoEvents
> sInput = MSComm1.Input
> If (Len(sInput) > 0) Then
> MSComm2.Output = sInput
> End If
> Wend


Posted by micropid on 21 July, 2004 - 1:07 am
hií

look you have to use mscomm control in visual basic, the mscomm control is a control that is include into visual basic its icon is like a phone.

into of its properties there are de comm 1 o comm 2 setting, speed, parity etc...

the instruction to read de port is input and the instruction to write is output is very easy to use.


Posted by Anonymous on 1 March, 2005 - 10:33 pm
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.


Posted by Krishnakant on 7 October, 2004 - 12:40 am
Even I am doing the same project i.e. sending & reciving messages using USB thru GSM modem.

If you got the code please send me at the email address below.

krishnapokhare@rediffmail.com


Posted by Andy on 20 October, 2004 - 5:15 pm
I would like a copy of the code too.

dube0014@umn.edu


Posted by M-S on 2 November, 2004 - 9:33 pm
i hope that u send the code to my e-mail too.

alsultan.m@gmail.com


Posted by Anonymous on 13 November, 2004 - 11:15 am
me also, thanks

fmbroilo@hotmail.com


Posted by Anonymous on 14 November, 2004 - 10:34 pm
Can somebody send me a sample code of how to interface the serial port with VB? basically i just want to read in 8 bits from and A/D converter.

If you got the code please send it to me at the email address below.

zoly_25@hotmail.com


Posted by Anonymous on 15 November, 2004 - 1:15 pm
Can somebody send me the sample code of how to interface the serial port with VB6 please?
can you send it to nglig@yahoo.com.au

thanks for your help.


Posted by Engr. Shahid bilal on 5 January, 2005 - 8:36 pm

1- go to "project" menu<br>
2- select "components"<br>
3- on control tab click the check box of "Microsoft Comm control 6.0"<br>
4- u will see a sign of telephone on General where u can find out text box, label, etc.<br>
5- select that MSCOMM control object and drag and drop on your Form1.<br>
6-double click on form1.<br>
7-copy & paste the following code:<br>


Private Sub Form_Load()


com1.CommPort = 2 ' comm port no.
com1.Settings = "1200,e,7,2"
com1.RThreshold = 24 'no. of chr to recive
com1.InputLen = 0 ' no. of chr on which oncomm event fires

com1.PortOpen = True 'open comm port

End Sub



Public Sub Com1_OnComm()
Dim txtBuf
Dim i As Integer
Dim c As Integer
Dim buffer
Dim stable
Dim EVMsg$
Dim ERMsg$
buffer = ""
txtweight.Text = ""
With com1

Select Case .CommEvent
Case comEvReceive
buffer = .Input
For i = 1 To Len(txtBuf)
c = Asc(Mid$(txtBuf, i, 1))
If (c < 32 Or c > 126) Then
txtweight = txtweight & "" & Hex(c) & ""
Else
txtweight = txtweight & Chr(c)
End If

Next i
'***************************************************************

' Error messages.
Case comBreak
ERMsg$ = "Break Received"

Case comFrame
ERMsg$ = "Framing Error"
Case comOverrun
ERMsg$ = "Overrun Error"
Case comRxOver
ERMsg$ = "Receive Buffer Overflow"
Case comRxParity
ERMsg$ = "Parity Error"

Case Else
ERMsg$ = "Unknown error or event"
'***************************************************************
End Select

End Sub

9- if any problem contact me, tell me how many char u want to tx/rx.



Posted by shahid on 13 January, 2005 - 3:54 pm
hi,

i have seen ur code for serial port communication using VB. it would be extremely useful if u wud tell me whether we need to put an command box. if yes, then what code should be written? ur code doesnt use a command box. then how do we receive our message back?

kindly reply back at this id.
thanx.
sravs_vani@yahoo.com


Posted by Girish on 14 January, 2005 - 10:55 am
That is ok. But how will i USB port to Send or Receive a Data in Vb6. Because MSCOMM control is not able to access USB port.


Posted by Anonymous on 28 September, 2005 - 10:24 pm
Hello there,

you can you a USB to RS232 converter.


Posted by lakshmi on 22 August, 2006 - 8:56 pm
Hello there,

Could you please help me by sending VisualBasic code which can be used to send and receive thru a USB to RS232 converter?

Appreciate your help in advance.

Thanks
lakshmi


Posted by Madhu on 19 January, 2005 - 6:17 pm
Hello

i am madhu. i am working as a vb programmer. i am also
having same problem in reading data from pbx and write it as a log file. if u have any code plz tell me.

my mail id madhu_8192@yahoo.co.in

i am waiting for ur reply.


Posted by Shekhar on 25 January, 2005 - 12:26 am
In the code snippet you have written:
for i = 0 to txtbuf
But, nowhere in the program the content of txtbuf
is mentioned. So i couldnt get ur point.

Thanking you
Shekhar


Posted by v.r.t.kumar on 27 January, 2005 - 4:45 pm
Respected Sir,

I am doing a project (weighing bridge software) which takes data from com1 port connected to a device.

The weigh-bridge vendor already given a software written in foxpro. In that software only it takes the data.

Now I am planning the same project write into vb. But in my code the data did not come from the com1 port. no data comes at all.

please give me a solution.

thaking you sir

with regards,
v.r.t.kumar


Posted by Anonymous on 15 March, 2005 - 10:25 pm
i am also trying for the same problem. If you have got the source code please send the below email id.

thanks & regards
b_v_annadurai@yahoo.co.in


Posted by kamal on 11 March, 2005 - 8:25 pm
i am geting a 424 error while running something in the line "com1.CommPort = 2 'comm port no." is wrong.


Posted by Payal sheth on 19 March, 2005 - 3:04 pm
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


Posted by sahil on 20 March, 2005 - 1:49 pm
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 : sahil.satpute@gmail.com

Thanks.


Posted by surya on 22 March, 2005 - 11:40 pm

Sir,

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.

What ever data I send is in txt_tx box and the receive data should be ib txt_rtx box.


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


Posted by Malik Saqib on 12 July, 2007 - 11:59 pm
Instead of this:

> i = MSComm1.OutBufferCount
> MsgBox i
>
> j = MSComm1.InBufferCount
> MsgBox j


Write this:

> i=mscomm1.output
> msgbox i

> mscomm1.input=j


Posted by Anonymous on 1 April, 2005 - 9:42 pm
i want a code to send and receive sms from pc.


Posted by AtcKit on 29 April, 2005 - 6:16 pm
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.


Posted by Kenny on 6 May, 2005 - 12:12 am
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


Posted by Anonymous on 2 June, 2005 - 11:37 pm

hi,

i'm working on a project that transfer a text data between two computer and use the following code:


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)
' txtReceive = txtReceive & MSComm1.Input
' 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
MsgBox "EOF received"
End Select
End Sub
*****************************************

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>
abelmesay97@yahoo.com

thank you!



Posted by engr Shahid bilal on 7 May, 2006 - 2:26 pm
Hi,
I used your code for getting 10 characters from an 8051 microcontroller thru the rs-232 serial interface with the com 1 port. so i modified threshold value as 10, and the com1.Settings = "9600,N,8,1". But it still isnt working..we tested our microcontroller code with the hyperterminal so there is no problem there.

plz do help us out, this is a part of our project. Thanks.


Posted by aditi on 30 May, 2006 - 11:38 pm
hey...

me too working on a similar project. it would be of great help if u could send me the code to transfer data serially using Vb 2 serial port...
Please!

thanx...
adITi
email:- aditi.upreti@gmail.com


Posted by Robbie on 22 January, 2011 - 12:14 pm
Not sure if i'm doing this right. Its my first time in a long time. I'm trying to build a CNC work station at home in my shop. I have read your com port program and it seam's strait forward enough. I'm trying to talk to a Stamp mother board Via (USB/com port) on the mother board i have wired a Hataci accallarator chip. Its Not meant for my application but it does read X Y Z axes AND Gforce.

This is the program that is loaded on the Stamp CPU eeprom and the Values it returns to the stamp program but i want to read the com port my self and using Stand alone VB program. The com. program u posted will probably work fine. The last time i programed anything was 17 years ago so im mostly trial and error right now.

'{$STAMP BS2pe}
'{$PBASIC 2.5}
' ==========
' ===============================================================
'
' File....... H48C_3-Axis.BS2
' Purpose.... Hitachi H48C 3-Axis Accelerometer Demonstration
' Author..... Copyright (c) 2005-2006 Parallax, Inc.
' E-mail..... support@parallax.com
' Started....
' Updated.... 02 FEB 2006
'
'
' ====================================================================== ===


' -----[ Program Description ]---------------------------------------------
'
' Test program for the H48C 3-Axis Accelerometer module.
'
' Connections:
'
' +------------+
' | * |
' CLK | o o | Vdd (+5v)
' | +--+ |
' DIO [ o | | o | CS\
' | +--+ |
' Vss | o o | 0G (free-fall indication)
' | |
' +------------+
'
' How it Works:
'
' An onboard MCP3204 12-bit ADC is used to read the VRef, X-, Y-, and
' Z-axis outputs from the Hitachi H48C accelerometer. The reference
' voltage output from H48C is 1.65 volts (3.3 / 2).
'
' After reading the reference voltage and an output channel the g-force
' for the channel is calculated with this formula:
'
' axis - vref 3.3
' G = ----------- x ------
' 4095 0.3663
'
' For use in the program the forumla can be simplified to:
'
' G = (axis - vref) x 0.0022
'
' To allow the display of fractional g-force in the integer system of the
' BASIC Stamp we multiply 0.0022 by 100 -- this will allow us to display
' g-force in 0.01g units.


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

Dio PIN 02 ' data to/from module
Clk PIN 08 ' clock output
CS PIN 03 ' active-low chip select


' -----[ Constants ]-------------------------------------------------------

XAxis CON 0 ' adc channels
YAxis CON 1
ZAxis CON 2
VRef CON 3

Cnt2Mv CON $CE4C ' counts to millivolts
' 0.80586 with **
GfCnv CON $3852 ' g-force conversion
' 0.22 with **

' -----[ Variables ]-------------------------------------------------------

axis VAR Nib ' axis selection
rvCount VAR Word ' ref voltage adc counts
axCount VAR Word ' axis voltage adc counts
mVolts VAR Word ' millivolts
gForce VAR Word ' axis g-force

dValue VAR Word ' display value
dPad VAR Nib ' display pad


' -----[ EEPROM Data ]-----------------------------------------------------


' -----[ Initialization ]--------------------------------------------------

Reset:
HIGH CS ' deselect module
DEBUG CLS, ' paint display
"=========================", CR,
"H48C 3-Axis Accelerometer", CR,
"=========================", CR,
CR,
" Count Volts G ", CR,
" ----- ----- -----", CR,
"VRef ", CR,
" X ", CR,
" Y ", CR,
" Z "


' -----[ Program Code ]----------------------------------------------------

Main:
FOR axis = XAxis TO ZAxis ' loop through each axis
GOSUB Get_H48C ' read vRef & axis counts

dValue = rvCount ' display vRef count
DEBUG CRSRXY, 6, 6
GOSUB RJ_Print

dValue = axCount ' display axis count
DEBUG CRSRXY, 6, (7 + axis)
GOSUB RJ_Print

mVolts = rvCount ** Cnt2Mv ' convert vref to mv
DEBUG CRSRXY, 13, 6, ' display
DEC (mVolts / 1000), ".",
DEC3 mVolts

mVolts = axCount ** Cnt2Mv ' convert axis to mv
DEBUG CRSRXY, 13, (7 + axis),
DEC (mVolts / 1000), ".",
DEC3 mVolts

' calculate g-force
' -- "gForce" is signed word

IF (axCount >= rvCount) THEN
gForce = (axCount - rvCount) ** GfCnv ' positive g-force
ELSE
gForce = -((rvCount - axCount) ** GfCnv) ' negative g-force
ENDIF
DEBUG CRSRXY, 20, (7 + axis), ' display g-force
" " + (gForce.BIT15 * 13),
DEC1 (ABS(gForce) / 100), ".",
DEC2 ABS(gForce)
NEXT
PAUSE 200
GOTO Main


' -----[ Subroutines ]-----------------------------------------------------

' Reads VRef and selected H48C axis through an MCP3204 ADC
' -- pass axis (0 - 2) in "axis"
' -- returns reference voltage counts in "rvCount"
' -- returns axis voltage counts in "axCounts"

Get_H48C:
LOW CS
SHIFTOUT Dio, Clk, MSBFIRST, [%11\2, VRef\3] ' select vref register
SHIFTIN Dio, Clk, MSBPOST, [rvCount\13] ' read ref voltage counts
HIGH CS
PAUSE 1
LOW CS
SHIFTOUT Dio, Clk, MSBFIRST, [%11\2, axis\3] ' select axis
SHIFTIN Dio, Clk, MSBPOST, [axCount\13] ' read axis voltage counts
HIGH CS
RETURN

' ---------------------------------------------------------------------- ---

' Right-justify value in 5-digit field
' -- move cursor first, then call with value in "dValue"

RJ_Print:
LOOKDOWN dValue, >=[10000, 1000, 100, 10, 0], dPad
DEBUG REP " "\dPad, DEC dValue
RETURN


Any help would be gratefully appreciated .Please forgive me my spelling and grammer. Robbie64


Posted by Anonymous on 18 November, 2004 - 1:59 pm
hi,

i'm having the same problem as yours. I try a lot of alternatives but still fail to do it. So, i hope that you can send me the vb code. Thanks... Your help will be appreciated.


Posted by Anonymous on 3 December, 2004 - 5:16 pm
Jumping on the bandwagon... i have a similar issue where I want to input data that is coming into the serial port, look at the last line of data, and then if that number in the last line is bigger than another number i want to create a pop-up window that says a message on it. Is this difficult to do? and if not, can someone send me the code on how you would do it? Thanks for your help.

kboukour@umich.edu


Posted by Neil Kingston on 5 December, 2004 - 11:20 pm

I would not recommend using infinite loops, instead use the MSComm event.


Private Sub MSComm1_OnComm()

Dim strInput As String
Dim intInput As Integer
Const intMax As Integer = 150

strInput = MSComm1.Input
' Locate the value you are interested in within the input string
' in this example it is the last three characters, which we convert to an integer
intInput = CInt(Right(strInput, 3))
If intInput > intMax Then
MsgBox strInput & " is too large, please make it smaller!"
End If

End Sub

Neil Kingston<br>
Data Layers

Connecting processes with IT<br>
http://www.opcware.com



Posted by asb1979 on 8 December, 2004 - 5:20 pm
Is it possible to send the text from visual basic thru serial com? Instead of using keyboard i will use pc to send input. (it works as keyboard.)

need help im novice in this language!!! Pls. send me a copy of your code. Thanks...

email add: cathy_1641@yahoo.com


Posted by Anonymous on 17 December, 2004 - 12:24 pm
Place a Microsoft Comm control on the form and send the data to its output property. For example if the data comes from txtAge the code would be

MSComm1.output = txtAge.text

Where MSComm1 is the Microsoft Comm control


Posted by Anonymous on 2 March, 2005 - 3:14 pm

Hi

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


Option Explicit

Private Sub Form_Load()

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


Posted by Thomas L. Burgin on 30 March, 2005 - 10:10 pm
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


Posted by Anonymous on 1 April, 2005 - 8:46 pm

Hi,

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.


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


Any help is greatly appreciated.



Posted by medo on 10 April, 2005 - 9:51 pm
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!


Posted by Anonymous on 27 October, 2005 - 11:51 pm
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?


Posted by cybermonk on 9 November, 2005 - 10:16 pm
hi scorpioboy!

try http://www.activexperts.com
products -
active experts sms messaging server.
activeexperts sms pager and toolkit.
should be interesting.

hope it works out.

cybermonk@domplace.com


Posted by vijay sohra on 8 January, 2006 - 12:03 pm
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


Posted by 2c worth on 29 January, 2006 - 9:13 pm
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


Posted by Jeff on 1 February, 2006 - 7:10 pm

I am trying to use two serial ports (and perhaps more) on the same form with VB6, I have no problems getting one MSComm event defined and working but when I try to add the second I get a "duplicate Definition" error. Any ideas as to why this wont work for me?

This code works great:


Dim WithEvents MSCommRatio1 As MSCommLib.MSComm

Private Sub Form_Open(Cancel As Integer)
'code to load the form and
'set up the comm
'port,
End Sub


Private Sub MSCommRatio1_OnComm()
'code to read the port at the correct time.
'and put the data were I want it
End Sub



This code gives the error:


Dim WithEvents MSCommRatio1 As MSCommLib.MSComm
Dim WithEvents MSCommRatio2 As MSCommLib.MSComm

Private Sub Form_Open(Cancel As Integer)
'code to load the form and set up
'the comm objects on two different ports
End Sub


Private Sub MSCommRatio1_OnComm()
'code to read the port at the correct time.
'and put the data were I want it
End Sub

Private Sub MSCommRatio2_OnComm()
'code to read the port at the correct time.
'and put the data were I want it
End Sub


Posted by zappata on 23 May, 2006 - 8:09 pm
you can perform one step at once and obtein good results too.
just to say that its possible using the same port.

think a litle more... after that a show you how.

regards


Posted by Anonymous on 2 April, 2007 - 11:24 pm
One more question... how to generate the list of com ports available in the system in vb?


Posted by donato aldea on 3 October, 2008 - 9:31 pm
Try this site.

http://www.developerfusion.com/article/21/com-ports-and-the-mscomm- control/2/




Posted by Hareen on 10 September, 2010 - 3:28 am
Can somebody send me a sample code of how to interface the serial port with VB? basically i just want to read in 16 bits from and A/D converter.

If you got the code please send it to me at the email address below.

hareensunny [at] gmail.com


Posted by sergui on 19 May, 2011 - 10:38 am
That is reading binary data bytes. We switched to SuperCom ActiveX for that. Replaced MSComm in no time (same functions) and got our binary data bytes. Look for a DEMO at www.adontec.com.

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
There's a fine line between courage and foolishness. Too bad it's not
a fence.
Advertise here
advertisements
Servo, steppers, analog, digital & web HMI - Fully Integrated!
Control.com is the largest Automation community on the web. Learn how to advertise here now...
Servo, stepping motor control, analog & web HMI in one system!
Time to incorporate data handling, web HMI and motion in one system!
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive