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.
Printable View
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.
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