Solved

file list box help

Posted on 2003-10-29
14
166 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading the Contents of a Directory In Access VBA 5 58
Microsoft Access combo box help 2 37
using web browser with BING 40 110
Recommendation vb6 to vb.net or others 14 109
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now