
Visit our shop for nerds in control lifestyle products.
- PC reliability?
- Windows, real time
- PID loops
- PCs vs. PLCs
- Replacing people
- MS 'monopoly'?
- Software quality
- Where do we go from here?
- Why pay?
-- J. B. White
www.control.com/rss/
To get a personalized feed, become a member at no cost.
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
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
http://www.elbingo.8k.com
at end there is a link VBCOMM, click it and enjoy!!!!
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
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.
http://programmers-corner.com/sourcecode/111?PHPSESSID=661cd95b75a 0265fbe84cbdc9ef60553
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.
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
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
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...
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
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
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.
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.
If you got the code please send me at the email address below.
krishnapokhare@rediffmail.com
If you got the code please send it to me at the email address below.
zoly_25@hotmail.com
can you send it to nglig@yahoo.com.au
thanks for your help.
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.
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
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
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.
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
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
thanks & regards
b_v_annadurai@yahoo.co.in
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
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.
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
> i = MSComm1.OutBufferCount
> MsgBox i
>
> j = MSComm1.InBufferCount
> MsgBox j
Write this:
> i=mscomm1.output
> msgbox i
> mscomm1.input=j
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.
could you kindly please help me over here? thks!
Kenny
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!
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.
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
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.
kboukour@umich.edu
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
need help im novice in this language!!! Pls. send me a copy of your code. Thanks...
email add: cathy_1641@yahoo.com
MSComm1.output = txtAge.text
Where MSComm1 is the Microsoft Comm control
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
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
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.
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!
Any solution?
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
its available with all vb enterprise edition
http://www.emant.com/681002.page
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
just to say that its possible using the same port.
think a litle more... after that a show you how.
regards
http://www.developerfusion.com/article/21/com-ports-and-t he-mscomm-control/2/
Patronize our advertisers!




