Solved

name,view,copy and rename seq files

Posted on 1998-07-27
5
172 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
Comment Utility
Edited text of question
0
 
LVL 9

Accepted Solution

by:
Dalin earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Dalin.... forget it.... I HAD A BRAIN FART...../.
EVERYTHING WORKS FINE !!!!!!!!!!!
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now