Hello everybody,

how can i import a text from notepad to a text box?:rolleyes:

Stick This in a module (or in the declarations of the form)

Public Sub LoadTextBox(NotepadFile$, XTextBox As TextBox)
Dim chk As String
Dim hld As String
If Dir(NotepadFile$, vbNormal) = "" Then
    MsgBox "File Not Found: " & NotepadFile$
    Exit Sub
End If

Open NotepadFile$ For Input As #1
Do Until EOF(1)
    Line Input #1, chk
    hld = hld & chk & vbNewLine
Close #1

hld = Left(hld, Len(hld) - 2)
XTextBox.Text = hld
End Sub

Then call it like this (from a button, or on form load, or whatever)

FName$ = "c:\path2yourfolder\notepadfile.txt"
LoadTextBox FName$, Text1

i will try it
thanks 4 ur time

Yes i tried this code it works if i know the path of the text file but what if opened the file using common dialog (open window) how can i know the path and how can i get the text?"


Simply pass the variable or object to the sub

FName$ = commondialog1.filename
LoadTextBox FName$, Text1