Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

vb6 single data type serial data

Status
Not open for further replies.

drzsmith

Newbie level 3
Joined
Mar 18, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
Hi I would like to transmit a single data type (vb6) using msconn.

how is this done?

thanks
 

create MScomm object in VB (IE MSComm1)

set the MScomm object properties according your requirements (baudrate, data size, parity and hanshake)

open the serial communication,
MSComm1.PortOpen = True

send data.
MSComm1.Output = data ' or what you need to send


remember to close the communcation before exiting the vb application
 

Single precision on VB6 is a IEEE 32-bit (4 byte) floating-point number... https://en.wikipedia.org/wiki/Single-precision_floating-point_format

590px-Float_example.svg.png


Check this article to know how to hack to use pointers in VB6

https://www.codeguru.com/vb/gen/vb_....php/c7495/How-Visual-Basic-6-Stores-Data.htm

So you need to get a pointer to your Single value, and a pointer to a string, then you need to use the CopyMemory from kernel32 to copy data from the memory position of the single , to the string... then reorder the string so that each byte of the single be at a character position...
after this you will be able to transmit the characters trough the com port..

You will need to cast the data bytes on the other end of com line in order to be able to use the single value again...

note: Keep in mind that you need to do it considering both Sender and receiver memory formats (big-endian or little-endian)

OR

You can just print the Single value to string and send the ASCII values trough com
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top