Murray Brown
asked on
VB 2005 code problem
Hi
I am having a problem with the following function that I brought over from VBA into VB 2005
The error is at the line marked 'XXXX and it reads .Selected is not a member of a ListView
Function sListSelection() As String
'returns a string separatted by commas of indices selected in a list box
Dim lngIndex As Long
Dim S As String
Dim Count As Long
Count = 0
With frmR.lsbActionR
For lngIndex = 1 To .Items.Count
If .Selected(lngIndex - 1) Then 'XXXX
If Count = 0 Then
S = CStr(lngIndex - 1)
Else
S = S & "," & CStr(lngIndex - 1)
End If
Count = Count + 1
End If
Next lngIndex
End With
sListSelection = S
End Function
I am having a problem with the following function that I brought over from VBA into VB 2005
The error is at the line marked 'XXXX and it reads .Selected is not a member of a ListView
Function sListSelection() As String
'returns a string separatted by commas of indices selected in a list box
Dim lngIndex As Long
Dim S As String
Dim Count As Long
Count = 0
With frmR.lsbActionR
For lngIndex = 1 To .Items.Count
If .Selected(lngIndex - 1) Then 'XXXX
If Count = 0 Then
S = CStr(lngIndex - 1)
Else
S = S & "," & CStr(lngIndex - 1)
End If
Count = Count + 1
End If
Next lngIndex
End With
sListSelection = S
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If .Items(IngIndex).Selected Then
but will be better:
Dim Index as Integer
For lngIndex = 1 To .SelectedIndices.Count
Index = SelectedIndices(IngIndex)
If Count = 0 Then
S = CStr(Index - 1)
Else
S = S & "," & CStr(Index - 1)
End If
Count = Count + 1
Next lngIndex