CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002
    Posts
    18

    Help me please! (transfer files over COM PORT)

    I want a program transfer file over COM PORT, simple is good, write on VB or VC++
    Have you got it?
    Thank you very much.

  2. #2
    Join Date
    Apr 2002
    Location
    Cleveland, Ohio, USA
    Posts
    200
    If you're just transferring a text file. you can use the code below copied from one of my apps. If you're going to transfer binary files it has to be a little different. Also, there are other ways to detect the end of the file tranfer (OnComm event comEvEof). There's pretty good documentation of this in the vb help files.


    In the samplle below, the user presses the Cancel button on the frmCancel form, which sets CancelSend=True and stops the transfer.

    '***** Open the Comm Port *****
    On Error Resume Next
    MDIForm1.MSComm1.PortOpen = True
    If Err Then MsgBox Error$, 48

    '***** Display the send dialog box *****
    CancelSend = False
    frmCancel.Label1.Caption = "Receiving File"
    frmCancel.Show , MDIForm1

    '***** Download the file *****
    hReceive = FreeFile
    Size = 0
    MDIForm1.MSComm1.InputLen = 0
    Do Until CancelSend = True
    If CommError = True Then Exit Do
    Dummy = DoEvents()
    FileText$ = FileText$ & MDIForm1.MSComm1.Input
    If CommError = True Then Exit Do
    Size = Len((FileText$))
    Loop

    '***** Close the port *****
    MDIForm1.MSComm1.PortOpen = False

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured