Solved

Transfer data via modem

Posted on 2003-11-17
7
977 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
  • 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 85

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 85

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 85

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 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

18 Experts available now in Live!

Get 1:1 Help Now