Solved

use object without put component on a form

Posted on 2000-04-10
3
170 Views
Last Modified: 2010-05-02

In fact I want to write code for a list box without putting a component in the form

I use this code but it doesn't work.

Private Sub Command1_Click()
Dim hj As FileListBox
Set hj = New FileListBox

.... my action code there ....


Set hj = Nothing
end sub

Someone can help me ?

Thanks a lot
0
Comment
Question by:elisaac
3 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2700620
See:

"HOWTO: Dynamically Add Controls to a Form with Visual Basic 6.0"
http://support.microsoft.com/support/kb/articles/Q190/6/70.ASP
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 total points
ID: 2700645
Do you want to read the files in a given directory?
If yes, the look at the Microsoft Scripting Library (Project References), which has the GetFolder method which returns a Folder object having a Files Collection

If you insist in some code similar that yours, you need to know that every control needs a parent window (handle)
You may use the
Set hj = Controls.Add ("VB.FileListBox", "tmp",me) which works from vb6 on.

Hope this helps
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2705101
Or.. Add the control to your form.. set it's Visible property to False.. and no one will be the wiser.. <smile>.

If indeed you are just after the Directory control, pay heed to AngelIII's comment and use a File System Object (FSO). There are also APIs that allow you to traverse a Directory path very rapidly.. but at your level, these are much more difficult to code than the FSO.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

777 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