Solved

file list box help

Posted on 2003-10-29
14
165 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

18 Experts available now in Live!

Get 1:1 Help Now