Solved

Transfer data via modem

Posted on 2003-11-17
7
983 Views
Last Modified: 2013-11-13
Hi
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
goodluck

open namefile for binary access read  as #filenum
input #filenum,variable
mscomm1.output=variable

or

open file name for input  as #filenum
input #filenum,variable
mscomm1.output=variable

0
Comment
Question by:mashal
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9762751
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.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 25 total points
ID: 9765763
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.

Idle_Mind
0
 

Author Comment

by:mashal
ID: 9770321
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
thanks
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9771023
Can you use Winsock on both sides?
0
 

Author Comment

by:mashal
ID: 9771114
hi Idle_Mind
I can't use winsock and I want open and read any size of file for reading and writing operation.
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9773159
can you network to that PC?  winsock is really the only way to transfer data over a modem/nic
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9773515
' 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
        Else
            data = Input(fileSize, ff)
            fileSize = 0
        End If
        MSComm1.Output data

        While MSComm1.OutBufferCount
            DoEvents
        Wend
    Wend
    Close #ff
End Sub
0

Featured Post

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!

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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