2 Replies - 1052 Views - Last Post: 07 February 2011 - 10:39 AM

#1 qtex  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 142
  • Joined: 24-October 09

WM 5.0 development in vb.net problem with txt.Contains(tb2.Text)

Posted 06 February 2011 - 01:14 PM

Hello,

I'm trying to filter listbox, but I have problem with that.
I develope it for windows mobile 5.0 and use framework 2.0.

My code :

For Each Itm As String In ListBox1.Items
            If Itm.Contains("Test") Then
                ListBox2.Items.Add(Itm)
            End If
        Next


It shows error : Contains is not member of string

thanks,

Is This A Good Question/Topic? 0
  • +

Replies To: WM 5.0 development in vb.net problem with txt.Contains(tb2.Text)

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1511
  • View blog
  • Posts: 5,916
  • Joined: 21-March 08

Re: WM 5.0 development in vb.net problem with txt.Contains(tb2.Text)

Posted 07 February 2011 - 06:23 AM

String.Contains doesn't exist in .Net Compact Framework 2.0. You will need to use IndexOf instead.

For Each Itm As String In ListBox1.Items
     If Itm.IndexOf("Test") >= 0 Then
         ListBox2.Items.Add(Itm)
     End If
Next



String.IndexOf will return a -1 if the string is not found. If the string is found, it will return the index of it.
Was This Post Helpful? 1
  • +
  • -

#3 qtex  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 142
  • Joined: 24-October 09

Re: WM 5.0 development in vb.net problem with txt.Contains(tb2.Text)

Posted 07 February 2011 - 10:39 AM

Thanks ! It works now.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1