Solved

name,view,copy and rename seq files

Posted on 1998-07-27
5
209 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON Response and request in VB6 application 11 1,069
Adding to a VBA? 6 93
Visual Studio 2005 text editor 10 56
Passing a Text Box name to a Sub 6 104
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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

752 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