[RESOLVED] Outputting to a listbox
Hi Everyone,
What am I doing wrong in this code?
VB Code:
lstDrive = lstDrive.AddItem & objDisk.DeviceID & vbNewLine
It is giving me this error:
Compile Error:
Argument not optional
I had this code outputting to a textbox using the code below. Now I would like it to go to a listbox instead.
VB Code:
lblID = lblID & " " & objDisk.DeviceID & vbNewLine
Re: Outputting to a listbox
You don't need vbNewLine with a ListBox.
Only one entry per line will ever be added.
Also, you don't need the concantination. For your listbox, all you need is
VB Code:
lstDrive.AddItem objDisk.DeviceID
Re: Outputting to a listbox
OK,
I took out the "vbNewLine" and used the code below.
VB Code:
lstDrive = lstDrive.AddItem & objDisk.DeviceID
It is still giving me the :
Compile Error:
Argument not optional
Then it highlites ".AddItem"
Re: Outputting to a listbox
Quote:
Originally Posted by Hack
Also, you don't need the concantination. For your listbox, all you need is
VB Code:
lstDrive.AddItem objDisk.DeviceID
This was the rest of my last post.
Re: Outputting to a listbox
ahhh, i c i c. It works now.
Hack,
I am trying to use a computer name (that was entered as data) from textbox "txtLookup", and I am trying to combine it from output from a listbox that gives a drive letter (example, C: ) how do I make it so that if I double click the "C:" inside of the listbox, it will open the machine's root of "C"?
I have this so far:
VB Code:
Shell "explorer " & "\\" & txtLookup & "\C$", vbNormalFocus
But how do I pull in the "C:"? I don't know how to get rid of the ":" after the C.
Re: Outputting to a listbox
You are designating a drive and a folder, so you need the ":"
You would also need the "\" so that your program knows that you are going after "c:\"
Re: Outputting to a listbox
This is an example of the address that I will need:
\\COMPUTERNAME\C$
"COMPUTERNAME" is in the textbox "txtLookup"
"C:" is in a listbox called "lstDrive"
VB Code:
Shell "explorer " & "\\" & txtLookup & "\C$", vbNormalFocus
The above code outpute "\\COMPUTERNAME\C$"
How do i strip the ":" away from the "C:" (located in the listbox), and have it go the address above?
Could you please show me the code? Thank ya.
Re: Outputting to a listbox
I'm a little confused. Do you need to replace the ":" with a "$" so that the end result is C$ instead of C:?
Re: Outputting to a listbox
Re: Outputting to a listbox
Well, there is a couple of ways you can do it.
Lets start with the textbox. You can replace the ":" with "$" in the textbox itself so C: never even gets to your Listbox, which, of the differenant ways, is the one I would recommend.
VB Code:
Private Sub txtLookUp_KeyPress(KeyAscii As Integer)
If KeyAscii = 58 Then KeyAscii = 36 'this will replace : with $ when you are typing
End Sub
Re: Outputting to a listbox
Hack,
I don't think we're on the same page. My listbox displays drive letters (example, C:, D:, G: ). I want to be able to double click the drive letter, and launch an explorer window to that drive on the remote machine. I want to be able to do this by pulling the computer name (for the remote machine) from "txtLookup".
I hope this helps you. I'm sorry I am making this confusing. :sick:
Re: Outputting to a listbox
OK, I figured it out. I made the below code and it works well. The only problem is that I had to do it for every letter in the alphabet. If anyone has a shorter way to do it, hit me up. I'd like to see it. Thanks guys for all your help.
VB Code:
If lstDrive = "C:" Then
Shell "explorer " & "\\" & txtLookup & "\C$", vbNormalFocus
End If