Solved

Send and receive data vi modem by mscomm in VB

Posted on 2003-11-29
11
425 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now