Solved

file list box help

Posted on 2003-10-29
14
168 Views
Last Modified: 2010-05-03
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) ?
0
Comment
Question by:ANGmoh
  • 7
  • 6
14 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9645595
Private Sub File1_DblClick()

   OpenFile Me.File1.Path & "\" & Me.File1.List(Me.File1.ListIndex)

End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9645833
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
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9646000
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,vbnullstring,vbnullstring,vbnormal
end sub
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:ANGmoh
ID: 9649080
Richie_Simonetti : the Open file is not working ...
something wrong with it ?  

shellexecute me.hwnd, "open",filelistbox1.path & "\" & filelistbox1.text,vbnullstring,vbnullstring,vbnormal
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9649449
sorry, my mistake:

Private Sub File1_DblClick()
      ShellExecute Me.hwnd, "open", File1.Path & "\" & File1.FileName, vbNullString, vbNullString, vbNormal

end sub
0
 
LVL 1

Author Comment

by:ANGmoh
ID: 9660369
Richie ... still the same .. cant ...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9660385
I did a test and it works with no problems, what happens exactly?
0
 
LVL 1

Author Comment

by:ANGmoh
ID: 9665875
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.
0
 
LVL 1

Author Comment

by:ANGmoh
ID: 9665889
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 .
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9670602
"...but in other format (.exe,.frm) , not in txt file . "
Sorry, i didn't understand. What did you mean with that?
0
 
LVL 1

Author Comment

by:ANGmoh
ID: 9670754
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 .
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9670866
do you have a file asociation for that kind of file?
0
 
LVL 1

Author Comment

by:ANGmoh
ID: 9670918
they are text document , should be open with notepad .
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
ID: 9671119
Change last parameter to vbNormalFocus
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question