Solved

Send and receive data vi modem by mscomm in VB

Posted on 2003-11-29
11
426 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

920 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

16 Experts available now in Live!

Get 1:1 Help Now