Advertisement
2002VB Files/ File Controls/ Input/ Output #17276

How to open a file with one line of code!

You create a funtion that can open a file with just one line of code.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Public Function Openf(frm As Form, Text As RichTextBox, Dialog As CommonDialog)
   On Error Resume Next
    Dialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*|" 'Edit the filter how you want it 
    Dialog.Flags = cdlOFNPathMustExist & cdlOFNHideReadOnly
    Dialog.Action = 1
    Screen.MousePointer = vbHourglass
    Text.Text = ""
    Text.LoadFile Dialog.filename
    frm.Show
    frm.Refresh
    Screen.MousePointer = vbNormal
End Function
Private Sub Command1_Click()
Call Openf(Me, RichTextBox1, CommonDialog1)
End Sub
Original Comments (3)
Recovered from Wayback Machine