Solved

use object without put component on a form

Posted on 2000-04-10
3
189 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

691 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