VB 6.0 Cntrls In VBE - 'DriveListBox', 'DirListBox' & 'FileListBox

G

Guest

Guyz,

I have just learnt how to add the 'DriveListBox', 'DirListBox' and
'FileListBox' controls that were always included in the toolbox with VB 3.0 /
4.0 / 5.0, but always missing in VBE 2005.

And I have managed to create a simple file browsing project with the
'DriveListBox',
'DirListBox' and 'FileListBox' controls with the following code on the
'Form1' form:-

Private Sub CmdExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CmdExit.Click
REM Exiting the program whenever the user clicks on the
REM 'Exit' button. Added on Tuesday 23rd January 2007.

REM Exiting the program. Added on Tuesday 23rd January
REM 2007.
End

End Sub

Private Sub Drives_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
REM Update the 'Path' property of the 'Directories' directory list
REM box whenever the user clicks on a drive listed in the 'Drives'
REM drive list box. Added on Tuesday 23rd January 2007.

REM Setting the 'Path' property of the 'Directories' directory list
REM box. Added on Tuesday 23rd January 2007.
Directories.Path = Convert.ToString(Drives.SelectedItem)

End Sub

Private Sub Directories_Change(ByVal sender As Object, ByVal e As
System.EventArgs)
REM Update the 'Path' property of the 'Files' file list box whenever
REM the user clicks on a directory listed in the 'Directories'
directory
REM list box. Added on Tuesday 23rd January 2007.

REM Updating the 'Path' property of the 'Files' file list box.
REM Added on Tuesday 23rd January 2007.
Files.Path = Directories.Path

End Sub

Remember that I am using Visual Basic Express 2005. When I run the program,
the code works. Selecting a drive letter in the 'Drives' DriveListBox
control changes
what is displayed in the 'Directories' DirListBox control which in turn
changes what is displayed in the 'Files' FileListBox' control.

Likewise, selecting a directory in the 'Directories' DirListBox' control
changes what is displayed in the 'Files' FileListBox control.

The sample project allows you to browse all local directories on your
computer and all remote directories on another computer.

The problem is that when I try to copy the controls and drop them into a
GroupBox control (which used to be the Frame control in VB 3.0 / 4.0 / 5.0)
and the same
program code are also copied, with the new controls being named 'Drives2',
'Directories2' and 'Files2'.

What happens when I try to run the project, is that the code for the
'Drives2',
'Directories2' and 'Files2' controls in the GroupBox control no longer works
whereas
the code for the 'Drives', 'Directories' and 'Files' controls outside the
GroupBox control do work.

i.e. clicking on a drive letter in the 'Drives' control outside the GroupBox
control updates the contents of the 'Directories' and 'Files' controls, but
clicking on a drive letter in the 'Drives2' control inside the GroupBox
control does not update the contents of the 'Directories2' and 'Files2'
controls.

What is missing? Where am I going wrong? How can I fix this problem?

I have been using VB 5.0 for nearly 10 years, and I have just recently
started exploring VBE 2005 after installing it last May.

Any help / advice would be most appreciated. Thanks in advance.
 
N

Newbie Coder

Blimey!

I haven't seen people use REM statemennts in VB for many years, but I have
in batch files when I write them sometimes. What's wrong with using '
Scanboy? Example:

' This is a comment
Application.Exit() ' The preceding code executes

Try not to use 'End' in .NET Scanboy because as you know it stops execution
at that point at is a harsh way of closing your app.

Sorry, but I don't have the time to improve your code, but I started with VB
3 too... In the days where the VB application itself was just about 3 MB in
total.

Newbie Coder
(It's just a name)
 
G

Galen Somerville

Scanboy said:
Guyz,

I have just learnt how to add the 'DriveListBox', 'DirListBox' and
'FileListBox' controls that were always included in the toolbox with VB
3.0 /
4.0 / 5.0, but always missing in VBE 2005.

And I have managed to create a simple file browsing project with the
'DriveListBox',
'DirListBox' and 'FileListBox' controls with the following code on the
'Form1' form:-

Private Sub CmdExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CmdExit.Click
REM Exiting the program whenever the user clicks on the
REM 'Exit' button. Added on Tuesday 23rd January 2007.

REM Exiting the program. Added on Tuesday 23rd January
REM 2007.
End

End Sub

Private Sub Drives_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
REM Update the 'Path' property of the 'Directories' directory list
REM box whenever the user clicks on a drive listed in the 'Drives'
REM drive list box. Added on Tuesday 23rd January 2007.

REM Setting the 'Path' property of the 'Directories' directory list
REM box. Added on Tuesday 23rd January 2007.
Directories.Path = Convert.ToString(Drives.SelectedItem)

End Sub

Private Sub Directories_Change(ByVal sender As Object, ByVal e As
System.EventArgs)
REM Update the 'Path' property of the 'Files' file list box
whenever
REM the user clicks on a directory listed in the 'Directories'
directory
REM list box. Added on Tuesday 23rd January 2007.

REM Updating the 'Path' property of the 'Files' file list box.
REM Added on Tuesday 23rd January 2007.
Files.Path = Directories.Path

End Sub

Remember that I am using Visual Basic Express 2005. When I run the
program,
the code works. Selecting a drive letter in the 'Drives' DriveListBox
control changes
what is displayed in the 'Directories' DirListBox control which in turn
changes what is displayed in the 'Files' FileListBox' control.

Likewise, selecting a directory in the 'Directories' DirListBox' control
changes what is displayed in the 'Files' FileListBox control.

The sample project allows you to browse all local directories on your
computer and all remote directories on another computer.

The problem is that when I try to copy the controls and drop them into a
GroupBox control (which used to be the Frame control in VB 3.0 / 4.0 /
5.0)
and the same
program code are also copied, with the new controls being named 'Drives2',
'Directories2' and 'Files2'.

What happens when I try to run the project, is that the code for the
'Drives2',
'Directories2' and 'Files2' controls in the GroupBox control no longer
works
whereas
the code for the 'Drives', 'Directories' and 'Files' controls outside the
GroupBox control do work.

i.e. clicking on a drive letter in the 'Drives' control outside the
GroupBox
control updates the contents of the 'Directories' and 'Files' controls,
but
clicking on a drive letter in the 'Drives2' control inside the GroupBox
control does not update the contents of the 'Directories2' and 'Files2'
controls.

What is missing? Where am I going wrong? How can I fix this problem?

I have been using VB 5.0 for nearly 10 years, and I have just recently
started exploring VBE 2005 after installing it last May.

Any help / advice would be most appreciated. Thanks in advance.
Apparently you multi-posted this to numerous news groups. I believe it was
answered in the classic vb groups.

If you had cross-posted, all groups would have seen the answer and you
wouldn't have to go look for it.

Galen
 
G

Guest

Scanboy said:
Guyz,

I have just learnt how to add the 'DriveListBox', 'DirListBox' and
'FileListBox' controls that were always included in the toolbox with VB 3.0 /
4.0 / 5.0, but always missing in VBE 2005.

And I have managed to create a simple file browsing project with the
'DriveListBox',
'DirListBox' and 'FileListBox' controls with the following code on the
'Form1' form:-

Private Sub CmdExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CmdExit.Click
REM Exiting the program whenever the user clicks on the
REM 'Exit' button. Added on Tuesday 23rd January 2007.

REM Exiting the program. Added on Tuesday 23rd January
REM 2007.
End

End Sub

Private Sub Drives_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)
REM Update the 'Path' property of the 'Directories' directory list
REM box whenever the user clicks on a drive listed in the 'Drives'
REM drive list box. Added on Tuesday 23rd January 2007.

REM Setting the 'Path' property of the 'Directories' directory list
REM box. Added on Tuesday 23rd January 2007.
Directories.Path = Convert.ToString(Drives.SelectedItem)

End Sub

Private Sub Directories_Change(ByVal sender As Object, ByVal e As
System.EventArgs)
REM Update the 'Path' property of the 'Files' file list box whenever
REM the user clicks on a directory listed in the 'Directories'
directory
REM list box. Added on Tuesday 23rd January 2007.

REM Updating the 'Path' property of the 'Files' file list box.
REM Added on Tuesday 23rd January 2007.
Files.Path = Directories.Path

End Sub

Remember that I am using Visual Basic Express 2005. When I run the program,
the code works. Selecting a drive letter in the 'Drives' DriveListBox
control changes
what is displayed in the 'Directories' DirListBox control which in turn
changes what is displayed in the 'Files' FileListBox' control.

Likewise, selecting a directory in the 'Directories' DirListBox' control
changes what is displayed in the 'Files' FileListBox control.

The sample project allows you to browse all local directories on your
computer and all remote directories on another computer.

The problem is that when I try to copy the controls and drop them into a
GroupBox control (which used to be the Frame control in VB 3.0 / 4.0 / 5.0)
and the same
program code are also copied, with the new controls being named 'Drives2',
'Directories2' and 'Files2'.

What happens when I try to run the project, is that the code for the
'Drives2',
'Directories2' and 'Files2' controls in the GroupBox control no longer works
whereas
the code for the 'Drives', 'Directories' and 'Files' controls outside the
GroupBox control do work.

i.e. clicking on a drive letter in the 'Drives' control outside the GroupBox
control updates the contents of the 'Directories' and 'Files' controls, but
clicking on a drive letter in the 'Drives2' control inside the GroupBox
control does not update the contents of the 'Directories2' and 'Files2'
controls.

What is missing? Where am I going wrong? How can I fix this problem?

I have been using VB 5.0 for nearly 10 years, and I have just recently
started exploring VBE 2005 after installing it last May.

Any help / advice would be most appreciated. Thanks in advance.


The work-around is this:-

1. Drop a label control on the form.

2. Set the 'AutoSize' property of the label control to FALSE.

3. Set the 'BorderStyle' property of the label control to 'Fixed3D'.

4. Make the 'Text' property of the label control an empty string.

5. Then position the 'Drives', 'Directories' and 'Files' controls so
that they appear to be inside the label. Resize the label if
necessary to accomodate the controls.

6. If you want the label's border around the 'Drives', 'Directories'
and 'Files' controls to have a title, drag another label control onto
top of the first label control and position the second label control
over the first label control so that the border around the 'Drives',
'Directories' and 'Files' controls appears to have a title, in a similar
fashion to the Frame control in VB 3.0 / 4.0 / 5.0.

7. Set the 'Text' property of the second label control to whatever
you like.

8. When you run the project, all you see is what appears to be a 3D
border around the drives, directories and files, with a title.

Nobody is any wiser, but only you know different.
 
G

Guest

Newbie Coder,

I am from the old school of programming. I believe in REM, WHILE ... WEND,
FOR ... NEXT, DO ... LOOP, etc., instead of symbols and abbreviations.

I am new to VB .NET development. What's the difference between 'End' and
'Application.Exit()'?


S
 
G

Guest

Galen,

I am not a regular on these ngs. Didn't know what ngs are out there,
so I just looked for ones that I thought were appropiate for my posts.

Besides, I am using mum's computer, which does not have a newsreader
installed whereas I have Newsrover installed on mine, so I am replying to
this via Microsoft's online web-based Usenet browser.


S
-----------------------------------------------------------------------------------
 
C

Cor Ligthert [MVP]

Galen,

I assume it was multiposted because I don't see the other posts in this
newsgroup.

Multiposters is wrong and should not get answers. While crossposting is very
handy because sometimes 2 persons can answer one problem, that they could
not do alone.

Cor
 
M

Michel Posseth [MCP]

:)


Even in VB classic i used ' instead of REM Rem is from pre GUI times basic
( C64 , Qbasic ,,,, )

End should never be used in a GUI or controls app it is only usable in a
code only project ( like a project in VB6 that only contains modules ) in
all other situations it is a ticking time bomb , as it unconditionally
inmediatly terminates the app

regrds

Michel
 
R

RobinS

You may be from the old school of programming, but you should think of
..Net as an opportunity to join the new school of programming. They'll
probably remove While/Wend in the next version (if they haven't
already).
For/Next and Do/Loop are still used, by the way.

Good luck.

Robin S.
--------------------------------
 
G

Guest

Guyz,

This is the Scanboy here again.

I have just had a "D'oh!" moment here.

I have been a bit stupid. The problem is with (the following are all on one
line):-

Private Sub Drives_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs)

and:-

Private Sub Directories_Change(ByVal sender As Object, ByVal e As
System.EventArgs)

All I needed to do was to add:-

Private Sub Drives_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Drives.SelectedIndexChanged

Private Sub Directories_Change(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Directories.Change

which fixed the problem. I am at a loss as to how and why the 'Handles'
part somehow got left off.


S
------------------------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top