-
Dim strPath As String
Dim iFFN As Integer
Dim strBuffer As String
On Error Resume Next
With CommonDialog1
.ShowOpen
If Err.Number = cdlCancel Then
Exit Sub
End If
strPath = .filename
End With
iFFN = FreeFile
Open strPath For Input As iFFN
strBuffer = Space(LOF(iFFN))
strBuffer = Input(LOF(iFFN), #iFFN)
Close #iFFN
Text1.Text = strBuffer
the code is working perfectly .But can u explain it from step
iffn = freefile.
-
Sure.
1. ShowOpen method of the CommonDialog control will open a dialog to select a file to open.
2. Then, you check the Error number (cdlCancel means that the user clicked cancel on the CommonDialog)
3. Memorize the path the user selected using FileName property.
4. Find out the available file number (using FreeFile function)
5. Open the selected file for Input (Read mode).
6. Prepare the strBuffer variable to have the same length as the file (using LOF(iFFN))
7. Read the file into strBuffer variable (using Input function)
8. Assign the new text from strBuffer to the Textbox (Text1)
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 11-11-1999).]
-
thanx Serge.It is clear now.