Solved

Send and receive data vi modem by mscomm in VB

Posted on 2003-11-29
11
429 Views
Last Modified: 2013-12-13
HI
I 'm VB programmer and I 'm writing programm that send and receive data via modem but I don't know how can recognize that when my all data has been received and close my file.
I open the file and i read file for binary and when i read file in the receive procedure i must recognize end of file and colse my file that data save it and close this file
please help me that recognize end of file .
I have another problem: i don't know how can send text that write in text box and show this text in another textbox( in receiver )
Thanks
0
Comment
Question by:asid_rock
  • 5
  • 3
11 Comments
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9849085
when you are reading and sending the data at the end of the file send a delimeter something like ~^~^~
at the recieving end if you find this pattern you know that the end of the file has been reached.

"I have another problem: i don't know how can send text that write in text box and show this text in another textbox( in receiver )"
if you want to send a character at a time then in the keypress event send the chr of the ascii value that u get. Prefer sending the data at one go its more optimum
0
 

Author Comment

by:asid_rock
ID: 9874741
hi
I have a problem with transfer file I want send 1 byte of file and send it to another pc and this operation until full of file transmited .and all of data transmit byte byte.
what variable do I use?and how can srite this programm in VB
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9879839
use a byte or you can use the chr function and convert to ascii and transmit as string.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:asid_rock
ID: 9881741
Hi bhagyesht
Thanks for Reply but I don't know how can read a file byte byte and then every byte sne to output buffer.?
Please help me.
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9894525
if you know how to read a string read a string by converting the byte to a string. or there is a sample in msdn.I shall post it later in the day
0
 

Author Comment

by:asid_rock
ID: 9900161
Hi bhagyesht
Thanks for Replay . I don't know how can send a byte with mscomm when inputmode=Binary.If you can know send me code.or tell me how can send several character in Binary mode with mscomm.
my primary goal is that send a file in Binary mode with mscomm.
please help me
thanks
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9901759
ok this code sends the textbox keys pressed one at a time

Private Sub Text1_KeyPress (KeyAscii As Integer)
   Dim Buffer as Variant
   
   ' Set and open port
   MSComm1.CommPort = 1
   MSComm1.PortOpen = True

   Buffer = Chr$(KeyAscii)
   MSComm1.Output = Buffer
End Sub



bhagyesh
0
 
LVL 9

Accepted Solution

by:
bhagyesht earned 125 total points
ID: 9901807
the following reads a file one byte at a time use the output method of mscomm to send it.
i dont have a modem or serial loopback hence cant test it. but you may need to convert the byte to a byte array and send it
Private Sub Command1_Click()
    Dim mybyte As Byte
    Dim myvariant
    Dim myfilelen As Long
    myfilelen = filelen("c:\1.bmp")
    Open "c:\1.bmp" For Binary As #1
    Dim i As Long
    For i = 1 To myfilelen
        Get #1, , mybyte
        myvariant = mybyte
        MSComm1.Output myvariant
        DoEvents
    Next
    Close #1
End Sub
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question