Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

file list box help

Posted on 2003-10-29
14
Medium Priority
?
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 total points
ID: 9671119
Change last parameter to vbNormalFocus
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Suggested Courses

618 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