Results 1 to 5 of 5

Thread: ***---Open a file using CommonDialogue---***

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    how can i open a file using a common dialogue instead of doing it this way:

    ____________________________________
    Dim i As Integer
    Dim temp As String
    i = 0
    CountAges = 0

    Open "a:\data.txt" For Input As #1

    i = i + 1
    Input #1, Names(i), Ages(i)
    CountAges = i
    _________________________________

    how do bring up the open dialogue box instead of accessing the file directly????

  2. #2
    Guest
    Code:
    Private Sub Command1_Click()
        Dim iFile As Integer
        On Error GoTo User_Cancelled
        With CommonDialog1
        .CancelError = True
        .DialogTitle = "Select a Text File.."
        .Filter = "Text (*.txt)|*.txt"
        .ShowOpen
        iFile = FreeFile
        Open .filename For Input As iFile
        Text1.text = Input(LOF(iFile), iFile)
        Close iFile
        End With
    User_Cancelled:
    End Sub

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    add the common dialog component to your project, put a common dialog control on your form and have something like:
    Code:
    Private Sub open_Click()
    CommonDialog1.ShowOpen
    'Set somekind of filter unless you want all files to show up
    Open CommonDialog1.FileName For Input As #1
    'And the rest of your code
    that should work.

  4. #4
    New Member
    Join Date
    Mar 2002
    Posts
    4

    COMMON DIALOGUE HELP PLEASE

    hi,
    I WANT THE FILE TO OPEN FOR THE USER TO EDIT WHEN HE CLICKS ON THE OPEN BUTTON IN THE COMMON DIALOGUE BOX OR WHEN HE DOUBLE CLICKS ON THE FILE.I SEARCHED ALL OF MSDN BUT IN VEIN CAN ANYBODY HELP ME WITH THIS PLEASE

    ASHRAF

    regards
    ashraf

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    what kind of files are we talking about here?
    -= a peet post =-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width