ANGmoh
asked on
file list box help
1) i have a driver list box , dir list box and a file list box , how can i do that when i double click on any file in the file list box , it'll automatically open the file ?
2) how can i list all the files' name within a folder to a ListBox ? ( not using a file list box) ?
2) how can i list all the files' name within a folder to a ListBox ? ( not using a file list box) ?
2) use Dir$ function
dim f as string
dim sPath as string
sPath="c:\windows\system\"
f=dir$(spath & "*.*",vbarchive)
do while f<>""
list1.additem spath & f
f=dir$
loop
dim f as string
dim sPath as string
sPath="c:\windows\system\"
f=dir$(spath & "*.*",vbarchive)
do while f<>""
list1.additem spath & f
f=dir$
loop
1)
'in general declarations section of form
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
sub filelistbox1_doubleclick()
shellexecute me.hwnd, "open",filelistbox1.path & "\" & filelistbox1.text,vbnullst ring,vbnul lstring,vb normal
end sub
'in general declarations section of form
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
sub filelistbox1_doubleclick()
shellexecute me.hwnd, "open",filelistbox1.path & "\" & filelistbox1.text,vbnullst
end sub
ASKER
Richie_Simonetti : the Open file is not working ...
something wrong with it ?
shellexecute me.hwnd, "open",filelistbox1.path & "\" & filelistbox1.text,vbnullst ring,vbnul lstring,vb normal
something wrong with it ?
shellexecute me.hwnd, "open",filelistbox1.path & "\" & filelistbox1.text,vbnullst
sorry, my mistake:
Private Sub File1_DblClick()
ShellExecute Me.hwnd, "open", File1.Path & "\" & File1.FileName, vbNullString, vbNullString, vbNormal
end sub
Private Sub File1_DblClick()
ShellExecute Me.hwnd, "open", File1.Path & "\" & File1.FileName, vbNullString, vbNullString, vbNormal
end sub
ASKER
Richie ... still the same .. cant ...
I did a test and it works with no problems, what happens exactly?
ASKER
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()
sPath = strLogDefaultDir & "\"
fullpathname = sPath & List1.Text
ShellExecute Me.hwnd, "open", fullpathname, vbNullString, vbNullString, vbNormal
end sub
i'v double clicked , but nothing happen.
Private Sub File1_DblClick()
sPath = strLogDefaultDir & "\"
fullpathname = sPath & List1.Text
ShellExecute Me.hwnd, "open", fullpathname, vbNullString, vbNullString, vbNormal
end sub
i'v double clicked , but nothing happen.
ASKER
i did try it out in a new form , yes it did ,open the files , but in other format (.exe,.frm) , not in txt file .
"...but in other format (.exe,.frm) , not in txt file . "
Sorry, i didn't understand. What did you mean with that?
Sorry, i didn't understand. What did you mean with that?
ASKER
what i mean is , you are able to open other files format except .txt file .
when i double click on aaa.txt , it wont open the file .
when i double click on aaa.txt , it wont open the file .
do you have a file asociation for that kind of file?
ASKER
they are text document , should be open with notepad .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OpenFile Me.File1.Path & "\" & Me.File1.List(Me.File1.Lis
End Sub