PDA

Click to See Complete Forum and Search --> : Help......


shan1
Nov 10th, 1999, 10:49 PM
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.

Serge
Nov 11th, 1999, 12:45 AM
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
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)



[This message has been edited by Serge (edited 11-11-1999).]

shan1
Nov 12th, 1999, 01:49 AM
thanx Serge.It is clear now.