Solved

Transfer data via modem

Posted on 2003-11-17
7
982 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
t-sql sp_addlinkedserver possible risks 3 116
Child Form in front 4 64
Automatically generate a pdf file from an excel file and email out everyday 2 72
RUNRMTCMD from AS/400 13 121
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

740 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