473,544 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RS232 port

1 New Member
How can I get data from an RS232 port in VB6?
Oct 19 '06 #1
2 3596
willakawill
1,646 Top Contributor
How can I get data from an RS232 port in VB6?
You use the communications control
Oct 19 '06 #2
albertw
267 Contributor
You use the communications control
hi
small sample - you may need to append settings etc..

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Settings = "9600,n,8,1"
  3. MSComm1.Settings = Settings
  4. MSComm1.Commport = 1
  5.  
  6. With MSComm1
  7.     .InputLen = 1
  8.     .RThreshold = 0
  9.     .SThreshold = 0
  10.     .InBufferSize = 10240  
  11.     .InputMode = comInputModeText
  12.     .Handshaking = 0
  13. End With
  14. End Sub
  15.  
  16. Private Sub Receive()
  17. FileName = App.Path & "\RS232.dat"
  18. Open FileName For Output As #1
  19.     Do
  20.     DoEvents
  21.     RxTxt = MSComm1.Input
  22. ' start capture if you get some input
  23. ' you may also wait for some other specific character
  24.     Loop Until RxTxt > vbNullString
  25.     inbuff = vbNullString
  26.  
  27.     Do
  28.     DoEvents
  29.     RxTxt = MSComm1.Input
  30. ' data is supposed to be separated by Chr(10)
  31. ' chose another separationmark if neccesary
  32.         If RxTxt = Chr(10) And Len(inbuff) > 0 Then
  33.             If Left(inbuff, 1) = Chr(10) Then inbuff = Right(inbuff, Len(inbuff) - 1)
  34.             Print #1, inbuff
  35.             inbuff = vbNullString
  36.         Else
  37.             If Len(RxTxt) > 0 Then
  38.             inbuff = inbuff + RxTxt
  39.             End If
  40.         End If
  41. ' data is supposed to end with Chr(3)
  42. ' chose another endmark if neccesary
  43.     Loop Until RxTxt = Chr(3)
  44. Close
  45. End Sub
  46.  
Oct 25 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
12744
by: Chris | last post by:
Here's the situation: I work at a scientific institution and I have a portable electronic device which is used to take measurements. The device produces a very small amount of numerical data, about 10 to 15 numbers per measurement. This operation is performed frequently and I would like to implement an automatic solution that moves this...
1
7808
by: Dan | last post by:
I wnat to see in browser an status from an device connected on rs232 port The java class for read from serial port is: //Serial.java import java.io.*; import java.util.*; import java.lang.*; import javax.comm.*;
0
2188
by: Jason T | last post by:
I've downloaded and installed the '101 Visual Basic and C# Code Samples' from http://www.microsoft.com/downloads/details.aspx?familyid=08e3d5f8-033d-420b-a3b1-3074505c03f3&displaylang=en I have used the 'Framework - Using the COM Port' sample, from a windows forms application, and it works perfectly. I have also use the 'Framework -...
6
9117
by: Ken Breit | last post by:
I am using the RS232.vb class to talk to the serial port. The problem I am having is when I try to read if anything is on the comm port. I call the read method, with the number of bytes I am expecting to read. As long as I know the length of the command that I will be getting on the input of the port it works great. The problem is when...
8
2043
by: Terry Olsen | last post by:
I'm trying to use the RS232 class that was in the Platform SDK (i think). Has anyone else used this with events successfully? Here's what i've got: ====================== Public WithEvents bbsPort As Rs232 = New Rs232 With bbsPort .BaudRate = baud .DataBit = dataBits .Parity = parity .Port = comPort
2
1442
by: Mika M | last post by:
Hi! My application uses Rs232-class, which was shipped with "101 VB.NET Samples\Framework - Using the COM Port". I need to sent certain kind of string into peripheral equipment attached to COM1-port , and after receiving this string of my application this equipment should return string back into my application. Is it possible by using...
2
5117
by: Wouter van Teijlingen | last post by:
Dear Readers, I was reading about how to control the COM and LPT port using VB .NET. I've found a lot of information, and it was very useful to me. I found an example program on the site of Microsoft. You can find it overhere: http://www.microsoft.com/downloads/details.aspx?FamilyID=075318ca-e4f1-4846-912c-b4ed37a1578b&DisplayLang=en I...
13
6838
by: jay.dow | last post by:
I want to write to the pins of an RS232 without using the serial protocol. The use would be every pin could act to complete a circuit in customized hardware. I could use python to communicate serially to a BASIC stamp or a Javelin stamp and then use the stamp to set however many pins as 0's or 1's but should it be that hard to do with...
4
5496
by: Dave Harry | last post by:
I found the RS232 class from MS's 101 VB samples. Writing to the port works fine. (I've got hyperterminal on the other comm port and a crossover cable between COM1 and COM2) The port is opened with: Public switchcom As New Rs232 switchcom.Open(2, 57600, 8, Rs232.DataParity.Parity_None, Rs232.DataStopBit.StopBit_1, 512)
5
3026
by: =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?= | last post by:
Hi, how can I access the RS-232 hardware interface using C# and .NET2.0 to send and receive messages to a hardware component? Christian
0
7420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7704
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5904
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4911
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1837
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
983
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
657
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.