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

x
?
Solved

use object without put component on a form

Posted on 2000-04-10
3
Medium Priority
?
198 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
[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
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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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

609 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