Transfer data via modem

I 'm VB programmer and my programm send text file to another PC with mscomm32 in VB
but I want send and receive any type of data (*.exe or *.avi or *.bmp, etc) and I don't know how
can open any type of file and read it and send data and another Pc receive this file and save it .
I open file binary but it can only read text file.i use this code.
please tell me how can open and read file and save it

open namefile for binary access read  as #filenum
input #filenum,variable


open file name for input  as #filenum
input #filenum,variable

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

winsock will be the best solution, if you want to see an example let me know, ill throw one up on my webserver for you.
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Don't use input #filenum, variable to read files in binary mode.

Use the Get() function

dim variable as string
variable = space(4096) ' read file in 4096 byte chunks
open namefile for binary access read  as #filenum
get #filenum,,variable
mscomm1.output=variable ' use winsock instead like NBrownoh suggested!

Of course, if the file is smaller that 4096 bytes then just read the whole thing.  If it is larger, then you have to to determine if their will be a smaller chunk remaining at the end to send.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mashalAuthor Commented:
I have a problem with mscomm32 because my buffer size is 1024 byte and my data that will be send is larger than output buffer how can receive this data in another PC ( mscomm.input) i must use array ?
please help me . my buffer is small and data is large and how can save data in another pc
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Can you use Winsock on both sides?
mashalAuthor Commented:
hi Idle_Mind
I can't use winsock and I want open and read any size of file for reading and writing operation.
can you network to that PC?  winsock is really the only way to transfer data over a modem/nic
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
' Sending the file...
Private Sub sendFile(fileName As String)
    Dim ff As Integer
    Dim fileSize As Long
    Dim data() As Variant
    If Dir(fileName) = "" Then
        MsgBox fileName & " does not exist."
        Exit Sub
    End If
    ff = FreeFile
    Open fileName For Input As #ff
    fileSize = LOF(ff)
    While fileSize
        If fileSize > 1024 Then
            data = Input(1024, ff)
            fileSize = fileSize - 1024
            data = Input(fileSize, ff)
            fileSize = 0
        End If
        MSComm1.Output data

        While MSComm1.OutBufferCount
    Close #ff
End Sub
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.