PDA

View Full Version : What is wrong with this "file list box" code



Borg
2005-01-07, 07:37 PM
Below is code for click event procedure. By the time I click the button I would
have selected some files in the referenced file list box.

The problem is that I expect strCurrDwgName to return each file name
as it iterates through the list. However it only returns the last file selected
and returns it once for each iteration..
Do I need a different property?


Private Sub cmdDWFIt_Click()
Dim intDwgIndex As Integer
Dim strCurrDwgName As String
For intDwgIndex = 0 To lstDrawings.ListCount - 1
If lstDrawings.Selected(intDwgIndex) = True Then
strCurrDwgName = lstDrawings.FileName
frmMain.Print strCurrDwgName
End If
Next intDwgIndex
End Sub

Ed Jobe
2005-01-07, 10:10 PM
First of all, how are you getting lstDrawings.Filename? A listbox doesn't have that property. In any event, its only getting set once. Use the index number you found in the Selected property with the List property to get the value.



If lstDrawings.Selected(intDwgIndex) = True Then
strCurrDwgName = lstDrawings.List(intDwgIndex)

Borg
2005-01-07, 10:19 PM
Thanks Ed, I can move forward now.

As far as your question goes. I don't know what to say other than "Filename"
shows up as a property for the object FileListBox in the object browser.

Ed Jobe
2005-01-08, 12:15 AM
I thought you were talking about a regular ListBox control. Are you working in vb or vba? If you've referenced that control from within vba, that control is not licensed for vba. You'll also have trouble distributing your dvb to other users, because they won't have that control installed.