|
-
Nov 11th, 2000, 09:58 PM
#1
Thread Starter
Junior Member
I have made a program with one form containing a DriveListBox, a DirListBox, and a FileListBox. What I want to know is how to make it so when a double click on a file in the file list box it opens that file.
I'd appreciate any help on this matter, thank you.
-
Nov 11th, 2000, 11:32 PM
#2
Member
Here, try this... this is assuming you are using notepad.
Code:
Shell ("C:\Windows\notepad.exe ") & (File1.FileName)
Don't forget this is just a sample and may vary on the program. And you must obviously change the current Drive & Dir for it to even SEE the file.
If at first you DO succeed, don't look too astonished!
-deadBird
=================
-
Nov 12th, 2000, 12:09 AM
#3
PowerPoster
if you are using a text box in your own program use this:
Code:
Dim FileName As String
Private Sub Command1_Click()
FileName = dir1.path & "\" & file1.filename
F = FreeFile
Open FileName For Input As #F
Text1.Text = Input$(LOF(F), F)
Close #F
End Sub
Private Sub file1_dblClick()
call Command1_Click
End Sub
-
Nov 12th, 2000, 12:28 AM
#4
Code:
Public 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 Const SW_SHOWNORMAL = 1
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_DblClick()
If Len(Dir1.Path) <= 3 Then d = Dir1.Path & File1.filename
If Len(Dir1.Path) > 3 Then d = Dir1.Path & "\" & File1.filename
ShellExecute Me.hwnd, vbNullString, d, vbNullString, "c:\", SW_SHOWNORMAL
End Sub
-
Nov 12th, 2000, 11:13 AM
#5
Assuming that you have files other than Text files, use the following code to open them.
Code:
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
Private Sub File1_DblClick()
ShellExecute hwnd, "open", File1, "", "", 1
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|