473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

RS232 port

How can I get data from an RS232 port in VB6?
Oct 19 '06 #1
2 3586
willakawill
1,646 1GB
How can I get data from an RS232 port in VB6?
You use the communications control
Oct 19 '06 #2
albertw
267 100+
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
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,...
1
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...
0
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...
6
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...
8
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...
2
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...
2
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...
13
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...
4
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...
5
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.