open file

almubarmeg
05-07-2003, 12:01 AM
Hello. my friends
i have a problem with files. when i choose a file name from "open window"
how can i put this file name into this code to work.
code 1:

Open "c:\myproject\nlwa.txt" For Input As #1

and the code for "open window "is

code 2:

With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "All Files (*.*)|*.*"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
sfile = .FileName
End With

clearly what i want is how to fit the selected file from the open window in code 1 in order to let the program read it .......the same problem with "save"

any help will be appreciated

sjp
05-07-2003, 12:24 AM
ur selected file from the dialog window is stored in the variable, sfile when u assign it
"sfile = .FileName"

so add ur code 1 below 2 and change it to

Open sfile For Input As #1

this will open the selected file
if u want onli text files u have to change ur filter to *.txt

mohanakannan
05-07-2003, 12:24 AM
Private Sub Command1_Click()
With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "All Files (*.*)|*.*"
.ShowOpen
If Len(.FileName) = 0 Then Exit Sub
sfile = .FileName
Open sfile For Input As #1 ' here open the file
End With
End Sub

almubarmeg
05-07-2003, 10:05 PM
sorry for being late .....thank for the help ...you always like that

Homer
05-08-2003, 12:02 AM
Private Sub Command1_Click()
With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "All Files (*.*)|*.*"
.ShowOpen
If Len(.FileName) = 0 Then Exit Sub
sfile = .FileName
Open sfile For Input As #1 ' here open the file
End With
End Sub


What does dlgCommonDialog represent?

MindGenius
05-08-2003, 12:13 AM
dlgCommonDialog: A Common Dialog control with the name set to "dlgcommondialog"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum