Solved

Send and receive data vi modem by mscomm in VB

Posted on 2003-11-29
11
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Starting up a Project

631 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