Solved

Transfer data via modem

Posted on 2003-11-17
7
979 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
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 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

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

Suggested Solutions

Title # Comments Views Activity
Windows Script Host failed (Access is denied.) error 6 109
How does CurrentUser work? 10 31
Hide vba in gp 7 83
Visual Studio 2005 text editor 10 35
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

895 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