Solved

use object without put component on a form

Posted on 2000-04-10
3
148 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 …
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…

763 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

10 Experts available now in Live!

Get 1:1 Help Now