Solved

name,view,copy and rename seq files

Posted on 1998-07-27
5
200 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
  • 3
  • 2
5 Comments
 

Author Comment

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

Accepted Solution

by:
Dalin earned 500 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

839 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