Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

browsing for a file

Status
Not open for further replies.

Jody72

IS-IT--Management
Sep 3, 2003
16
US
I'd like to add a command before everything where the user can browse for a file to be edited. Also it needs to be able to resave the edited file with the same name, but different extension. As it stands now, the file has to be named tom.acl and I need to have the ability to run it on all acl files without having to rename them.

Basically open *.acl --> edit file --> save *.cl

Here's what I've got so far:

Private Sub Command1_Click()
Dim first, last, Space As String
Dim OutRecord(80), NewRecord As String
Space = " "
Open App.Path & "\Tom.Acl" For Input As #1
Open App.Path & "\Tom.cl" For Output Shared As #2
' Read in record reformat and write out
' Remove col 1 len 8 left just

Do While Not EOF(1) ' Loop until end of file.
Line Input #1, first ' Read data
'Debug.Print first ' Print data to Debug window.
'
'OutRecord
i = 0
For j = 9 To 80
i = i + 1
OutRecord(i) = Mid(first, j, 1)
Next
' perpare output record
i = 0

NewRecord = Space
Do While i < 80
NewRecord = NewRecord & OutRecord(i)
i = i + 1

Loop
'Write #2,
Print #2, NewRecord

Loop

Close #1 ' Close file.
Close #2
Command1.Visible = False ' Set to invisible.
Command2.Visible = True ' Set to visible.

End Sub

Private Sub Command2_Click()

End


End Sub

 
You could use a FileListBox and (if required) a DirListBox for your user to browse for the files.

You will find that your process to remove the first 8 characters of a string can be simplified and speeded up by using the Mid keyword (see VBHelp)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top