How to configure RS232 port in Visual Basic 6

A

Thread Starter

Ashwini

Hello friends,

I want to connect RS232 port using VB6. Can any one help me to know how can I connect RS232 port? I am looking for code samples to configure RS232. I am using the Digital Oscilloscope as communication equipment from testing instrument and transferring it to the PC through RS232. Can any one help me to know coding to initialise the scope and configure the RS232 in visual basic 6?

Thank you,
mail me back to [email protected]
 
hi

use mscomm control for serial communication. just set its commport & baud rate property. it is very simple to use.
 
<p>Open timer and put the down program inside it. also built label. do not forget to run the timer and match its speed acording to the device serial port which will be 9600 buad rate also, via PC com port # 1
<pre>
Dim var1$, i&, RS As String
If (MSComm1.PortOpen = False) Then
MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 13
MSComm1.PortOpen = True
Else
End If
Do
DoEvents
RS = MSComm1.Input
var1 = var1 & RS
Loop Until InStr(RS, vbCr)
If Len(var1) >= 1 Then
var1 = Mid(var1, 2, Len(var1))
MSComm1.PortOpen = False
label1.Caption = Trim(Str(Val(var1)))
End If
</pre>
<p>[email protected]
 
There is a good demo in the Samples section of Microsoft Help & Support:
http://support.microsoft.com/default.aspx?scid=kb;en-us;140880 (Search for article 140880 if the link breaks)

That will give you a starting point. From there, search for "serial API" on the Microsoft web site and you will find several more articles. Look for the links that start with 'msdn'.

Sealevel Systems (http://www.sealevel.com) includes help files and code samples for C++ and VB on the CD that ships with their serial products.
 
<p>First open timer and put the down code inside this timer. Also build label. Do not forget to run the timer by its interval value and match its speed acording to the device serial port which will be 9600 baud rate also, via PC com port #1.
<pre>
Dim var1$, i&, RS As String
If (MSComm1.PortOpen = False) Then
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 13
MSComm1.PortOpen = True
End If
Do
DoEvents
RS = MSComm1.Input
var1 = var1 & RS
Loop Until InStr(RS, vbCr)
If Len(var1) >= 1 Then
var1 = Mid(var1, 2, Len(var1))
MSComm1.PortOpen = False
label1.Caption = Trim(Str(Val(var1)))
End If
</pre>
<p>talshater @ hotmail. com
 
To build comm control tool, press Ctrl+T. You will get on Tools screen. Look for Microsoft Comm Control 6.0, and check the box, then confirm by OK. You will see Telephone Icon in the left hand side. Take this Telephone icon on the project form.

talshater @ hotmail.com
 
Top