Results 1 to 3 of 3

Thread: Open FIles in VB

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    derby,UK
    Posts
    38

    Post

    How do you open any file inc exe's in VB
    I think its got something to do with "shell"

    Any suggestion (apart from common dialogs)

    Thanks

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    This requires the OPEN statement:

    Open "TESTFILE" For Input As #1
    ' Close before reopening in another mode.
    Close #1

    This is copied directly from the help file:
    Syntax

    Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]

    The Open statement syntax has these parts:


    pathname Required. String expression that specifies a file name¾may include directory or folder, and drive.

    mode Required. Keyword specifying the file mode: Append, Binary, Input, Output, or Random. If unspecified, the file is opened for Random access.

    access Optional. Keyword specifying the operations permitted on the open file: Read, Write, or Read Write.

    lock Optional. Keyword specifying the operations permitted on the open file by other processes: Shared, Lock Read, Lock Write, and Lock Read Write.

    filenumber Required. A valid file number in the range 1 to 511, inclusive. Use the FreeFile function to obtain the next available file number.

    reclength Optional. Number less than or equal to 32,767 (bytes). For files opened for random access, this value is the record length. For sequential files, this value is the number of characters buffered.
    Good luck,

    [This message has been edited by DiGiTaIErRoR (edited 02-13-2000).]

  3. #3
    Member
    Join Date
    Jan 2000
    Posts
    35

    Post

    If you are wanting to run the file using the default viewer for that particular file; try this.

    Private Declare Function ShellExecute _
    Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, ByVal lpOperation _
    As String, ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long
    '
    '
    Public Sub OpenFile(Path As String)
    Call ShellExecute(App.hInstance, "Open", _
    Path, "", Path, 1)
    End Sub


    To use : OpenFile "C:\MyFile.txt"

    Help?

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