Solved

copy a file to COM1

Posted on 2004-04-07
6
1,970 Views
Last Modified: 2006-11-17
How do I copy a file from the hard drive to COM1: in VB6?
0
Comment
Question by:Antrach
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10777231
You need to use the MSCOMM controls.


0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10777239
MSComm control works quite well for this:

Add it to your components and place an instance on the form:

Private Sub Form_Load()
  With MSComm1
    .Settings = "9600,n,8,1"
    .CommPort = 1
    .PortOpen = True
  End With
End Sub

Private Sub Form_Unload()
  MSComm1.PortOpen = False
End Sub

Private Sub cmdSend_Click()
  MSComm1.Output = "Hello this is text out"
End Sub

Private Sub cmdReceive_Click()
  Dim strInput As String
  strInput = MSComm1.Input
  MsgBox strInput
End Sub

This is the simplest method of using the control as you are only sending and receiving on demand. The control has a single event _OnComm() which will allow you to run in an event-driven mode.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 10777256
So as you can see... to send a file it would be easily accomplished with.


the following code will open a MSComm control and send a text file line by line over comm 1.


With MSComm1
    .Settings = "9600,n,8,1"
    .CommPort = 1
    .PortOpen = True
End With


dim data as string
Open "File.txt" for input as #1
do while eof(1) = false
line input #1,data
MSComm1.Output = data
loop
close #1


MSComm1.PortOpen = False
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 10777375
Does this work?

dim FileInfo
open "HardDriveFile" for input as #1
open "Com1:" for output as #2
while not eof(1)
 line input#1, FileInfo
 print #2, FileInfo
wend
close #1
close #2
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 10777398
or just

shell "copy HardDriveFile com1:"
0
 

Author Comment

by:Antrach
ID: 10782976
MSComm component worked well sending a text string out the comm port, but did not work attempting to mimic a filecopy command.  The Do-While loop had no effect on the serial printer.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

803 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