filelistbox and exe file

vb6 Grenada
  • 14 years ago

    hi,
    I have a filelistbox in my projext.FileListBox contains a list of files.My problem is when i click on a particular file ,it should open in notepad.how to do this.

    i tried this code it works,but it just opens the notepad but how to open a particular file

    Shell("C:\windows\system32\notepad", vbNormalFocus)

    thank u

  • 14 years ago

    You need to tell notepad the name of the file

    dim s as string: s = "C:\windows\system32\notepad &1"

    s = replace(s,"&1",pathtofile)

    shell s,vbnormalfocus

    should do the trick

     

  • 14 years ago
    Hi,

    The following code assumes that you have added a Directory ListBox (Dir1), a Drive Listbox (Drive1) and a File Listbox (You've guessed it.... File1) to your Form:

    Private Sub Dir1_Change()
    File1.Path = Dir1.Path
    End Sub

    Private Sub Drive1_Change()
    Dir1.Path = Drive1.Path
    End Sub

    Private Sub File1_Click()
    Dim strFile As String
    Dim dTaskID As Double, strPath As String
    strFile = File1.Path
    If Right(strFile, 1) <> "\" Then strFile = strFile & "\"
    strFile = strFile & File1.FileName
    strPath = "C:\Windows\System32\notepad.exe"
    dTaskID = Shell(strPath + " " + strFile, vbNormalFocus)
    End Sub



















  • 14 years ago
    Sorry ktq53,

    Your solution wasn't there when I started typing!!  I'm a slow typer LOL!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An idiot with a computer is a faster, better idiot” - Rich Julius