Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

name,view,copy and rename seq files

Posted on 1998-07-27
5
Medium Priority
?
226 Views
Last Modified: 2010-05-03
my file is called xzt.seq. It is on the C drive. How do I, with a command button:
1) rename it to (Jan, feb, mar,......dec.seq) to be stored on A drive. I know I will need 'IF EXIST' for this. If jan,feb,mar are on the A drive I need the code for apr.
2.) now I need to view all the files on A drive,( jan.seq thru dec.seq ) with a commmand button, select one, load it to C drive and rename it to zxt.seq so I can run that months data. I anm using vb4-32bit
0
Comment
Question by:hjaycox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:hjaycox
ID: 1466868
Edited text of question
0
 
LVL 9

Accepted Solution

by:
Dalin earned 2000 total points
ID: 1466869
hjaycox,
Try this, let me know if you have questions.
Regards
Dalin

'Declare
'In General Declaration Area:

Dim FileArray(1 to 12) as String

' in Form load
FileArray(1)= "A:\Jan.seq"
FileArray(2)="A:\Feb.Seq"
.
FileArray(12) = "A:\Dec.Seq"

'Drop a command button, name it cmdFromCtoA, in the click event,
add the code

Dim i as Integer
Dim lString as String
For i = 1 to 12
    ' Try to see if the file exist
    lString = Dir(fileArray(i))
    If lString = ""
       ' This is the file not in
       lString = fileArray(i)
       Exit for
       End IF
   Next i
FileCopy "C:\xzt.seq" lString

Drop a commanDialog Box, name it comdial, and drop a command button, name it cmdFromAtoC, add the code:

Dim lString as String

On Error GoTo FileErrorHandler

'Get a file name From the User
comdial.DialogTitle = Title
comdial.Filter = "All Files|*.*"
comdial.Action = 2
lString = comdial.filename


FileCopy lString "C:\xzt.seq"

Exit Sub

FileErrorHandler:
Err.Clear
'Resume Next or handle your error


0
 
LVL 9

Expert Comment

by:Dalin
ID: 1466870
hjayCox,
You may also want to check if xzt.seq exist when you copy from a to C:  You can add:

Dim lCFile as String
lCFile = Dir("C:\xzt.seq")
If cFile > "" then
   'Delete it? Use Kill
   ' Kill "C:\xzt.seq"
   End If

Regards
Dalin

0
 

Author Comment

by:hjaycox
ID: 1466871
things work great EXCEPT. I cannot copy from C to A.
FileCopy "C:\xzt.seq" lString  is the problem area. [I think]
I believe the format for filecopy [is] "c:\xyz.seq", "a:\abc.seq"
I do not understand why it will work from a to c and not c to a
 For a to c I have had to modify your code from:
comdial.DialogTitle = Title
comdial.Filter = "All Files|*.*"
comdial.Action = 2        'save as
lString = comdial.filename
to                 :comdial.DialogTitle = Title
                    comdial.Filter = "All Files|*.*"
                     comdial.Action = 1      ' open
                    lString = comdial.filename
as comdial.action = 2 opened the diag box as SAVE AS while
#1 = open
I then had to ADD
comdial.Action = 6    'copy
lString = comdial.filename
filecopy IString "c:\xzt.seq" and it works, but in c to a filecopy "c:\xzt.seq" IString nothing happens, AND I get NO error flags.
There is no fileErrorHandler in the program at this point.
HELP !!!!!!!
0
 

Author Comment

by:hjaycox
ID: 1466872
Dalin.... forget it.... I HAD A BRAIN FART...../.
EVERYTHING WORKS FINE !!!!!!!!!!!
thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

721 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