Need Example Code for Using ReadStr Method(Read 15185 times)
Need Example Code for Using ReadStr Method on: May 27, 2008, 05:48:37 PM
Does anyone have any example code that uses the Serial ActiveX Control method ReadStr to read strings into Visual Basic 6.0.  My setup is an analytical balance connected to my PC via an RS232 serial port.  I am using Visual Basic to code the application.  The balance has a PRINT key that when pressed sends the weight displayed on the balance to the PC as a string via the serial port.  I want to read this string into my code. 

I have played around with the code sent with the demo version of the ActiveX software, but I believe it reads the data one character at a time and must be pieced back together. 

Anyway, any help will be appreciated.
« Last Edit: May 27, 2008, 05:50:26 PM by cdwell1965 »

Re: Need Example Code for Using ReadStr Method Reply #1 on: May 28, 2008, 12:53:53 PM

1) Please, be informed that ReadStr method reads a string from serial port input buffer. To read more about ReadStr method, please refer to User Manual for Serial Port ActiveX Control:

Serial Port ActiveX Control Manual -> Reference -> Methods -> ReadStr.

2) I kindly ask you to look at our compiled example, which goes along with trial version download:

Start -> All programs -> Eltima Software -> Serial Port ActiveX Control DEMO -> Development Samples -> VB6.

Re: Need Example Code for Using ReadStr Method Reply #2 on: May 28, 2008, 03:47:27 PM
I understand what it is supposed to do but the user manual is not what I would consider user-friendly when you are trying to learn how to use your control.  The example code simply uses the Read method, not the Readstr.  Do you have other examples that can be shared with the user.  If I can get this to work the way I want it to work, I would most likely purchase your ActiveX control for future development because I like it much better than MSComm.

If nothing else, can you tell me if the ReadStr method when executed must be read into a string variable or an array of string?  Does it read the contents of the input buffer and convert it to an ASCII string that can be used directly? 

I have a current workaround but would like to simply read the complete string then manipulate that in my code.

Re: Need Example Code for Using ReadStr Method Reply #3 on: May 29, 2008, 06:54:24 PM
1)    ReadStr will return the string. Please note that it is not allowed to use limitation if there are symbols with the code zero:

str = sport.ReadStr ()
ReadStr will read all data and return it as a string (convert it automatically in the Unicode)

2)   ReadVariant will return array of bytes:
arr = sport.ReadVariant (10)
It means that it attempted to recoup 10 bytes from the port.

Re: Need Example Code for Using ReadStr Method Reply #4 on: June 11, 2008, 06:23:40 PM
Hi all,

Likewise, I have a problem using and understanding this method. I am developing in Visual Datafex and when i call this method the data returned to a string is broken up. For example, I receive a value 0.984, but it appears as 0, does a carriage return, then outputs on next line 984. The application I am developing is reading weighings from a scale connected to a COM port. If anyone, can help me on this problem I would be most grateful.


Re: Need Example Code for Using ReadStr Method Reply #5 on: June 13, 2008, 09:28:20 AM

Please, note that symbol NULL is an indicator of the string end. I would recommend you to use Read Method or Readvariant Method.


Sitemap 1 2 3 4 5