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
Loop
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
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Simply pass the variable or object to the sub
FName$ = commondialog1.filename
LoadTextBox FName$, Text1
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215