4 Replies - 323 Views - Last Post: 12 July 2014 - 05:39 PM Rate Topic: -----

#1 bubu31  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 14

getting error when returning integer list

Posted 11 July 2014 - 10:30 PM

i getting error at Return IntList saying that

Value of(Type) 'system.collection.generic.list(of integer) cannot be converted to Integer'

 Function FindItem(ByVal LV As ListView, ByVal TextToFind As String) As Integer

        Dim IntList As New List(Of Integer)

        ' Loop through LVs ListViewItems.
        For i As Integer = 0 To LV.Items.Count - 1
            If Trim(LV.Items(i).Text) = Trim(TextToFind) Then
                ' If found, return the row number
                ' Return (i)
                IntList.Add(i)
            End If

            For subitem As Integer = 0 To LV.Items(i).SubItems.Count - 1
                If Trim(LV.Items(i).SubItems(subitem).Text) = Trim(TextToFind) Then
                    ' If found, return the row number
                    ' Return (i)
                    IntList.Add(i)
                End If
            Next
        Next
        ' If not found, then return -1.

        Return IntList

    End Function


Is This A Good Question/Topic? 0
  • +

Replies To: getting error when returning integer list

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3480
  • View blog
  • Posts: 11,844
  • Joined: 12-December 12

Re: getting error when returning integer list

Posted 11 July 2014 - 10:39 PM

Quote

Value of(Type) 'system.collection.generic.list(of integer) cannot be converted to Integer'

This error message is very clear. You have declared that you will be returning an Integer but you are attempting to return a list of integers.

What do you want to return: an integer or a list of integers..
Was This Post Helpful? 0
  • +
  • -

#3 bubu31  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 14

Re: getting error when returning integer list

Posted 11 July 2014 - 10:51 PM

i want to return a list of integers
Was This Post Helpful? 0
  • +
  • -

#4 bubu31  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 04-July 14

Re: getting error when returning integer list

Posted 11 July 2014 - 11:14 PM

Please help ?? i have no idea
Was This Post Helpful? 0
  • +
  • -

#5 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,086
  • Joined: 02-July 08

Re: getting error when returning integer list

Posted 12 July 2014 - 05:39 PM

Everything after the As keyword is the return Type.

Function FindItem(ByVal LV As ListView, ByVal TextToFind As String) As List(Of Integer)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1