Capitalize Drivelistbox
Gutentag!
I am working in VB6 and want to capitalize the drive letters in a drivelistbox when the form loads. Any suggestions?
Thanks in advance,
sweezapizza
e.g. The drive list box displays c: or a: and I want them like C: and A:
# 1 Re: Capitalize Drivelistbox
Hello!
Well, AFAIK, there is no inherent way to do this with the drivelistbox. I'd give a suggestion to use an ImageCombo ( a component which you can add to the toolbox. It is basically a combobox, which can show images as well ), then use a certain means ( for example the FileSystemObject, or even API ) to load all the available disk names into that ImageCombo.
Just a suggestion..
# 2 Re: Capitalize Drivelistbox
Hmmmm. There is no way to stream the drives into a string then spit them back out using UCASE?
Thanks for replying though!
swizzapizza
# 3 Re: Capitalize Drivelistbox
Yeah, that's right. The List() property of the DriveListBox is write protected.
You could use an invisible DriveListBox and copy the items to a normal ListBox (or an image combo like Hannes suggested) which is visible instead.
There you could go
Private Sub CopyDriveListToCombo()
Dim i%, a$
Combo1.Clear
For i = 0 To Drive1.ListCount - 1
a$ = Drive1.List(i)
Mid$(a$, 1, 1) = UCase(Mid$(a$, 1, 1))
Combo1.AddItem a$
Next
Combo1.ListIndex = Drive1.ListIndex
End Sub
If you want images, you'd have to look for an image combo control in the web.
WoF at 2007-11-9 19:34:00 >

# 4 Re: Capitalize Drivelistbox
NIZZIE! (nice)
Thanks WoF
# 5 Re: Capitalize Drivelistbox
swizzapizza, I've worked something out for you.
Basically it explorers WoF's and my comments about the ImageCombo component. It works, and does everything you need, but, I am going to give you some keypoints you will need to study up on, because you need to "learn how to fish" ( as the saying goes ) as well ..
Study these :
ImageCombo (http://support.microsoft.com/kb/q186896/)
ImageList (http://www.developerfusion.co.uk/show/13/)
Arrays (http://searchwarp.com/swa258112.htm)
EDIT :
Just as a side note, in the ImageList, I've only provided three images ( hard disk, Stiffy drive, Cd drive ), it's logical that you'd need to include more images for more drives.
# 6 Re: Capitalize Drivelistbox
That's great, Hannes.
Only there seems to be a little error in this line where you add the item to the ImageCombo
ImageCombo1.ComboItems.Add TempLoopCount, DriveArray(DriveCounter), DriveArray(DriveCounter), TempLoopCount 'show the images, as well as drive letters
You give TempLoopCount as index into the imagelist. That would soon exceed its index after three drives.
You'd have to determine what type of drive it is and choose the number accordingly.
Also we could add an image for network drives.
WoF at 2007-11-9 19:37:02 >
