Search Tools Links Login

How to open a file with one line of code!

Posted: 2002-06-01
By: ArchiveBot
Viewed: 62

Filed Under:

VB6 Code Cache

No attachments for this post

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

Original Author: Nick Pordash


Form is your Form, RichTextBox is your RichTextBox, and
Commondialog is your Commondialog.


This code requires a Commondialog and a RichTextBox.


The file you just open in the richtextbox you picked.

API Declarations


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
    Screen.MousePointer = vbNormal
End Function
Private Sub Command1_Click()
Call Openf(Me, RichTextBox1, CommonDialog1)
End Sub

Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.