问题

想要实现一个功能

比如一个listbox1 内容为

fad1saZZZffffdsfffdfg

fdsaafd999afdaffaf

fd3safdafdsa999fdssafd

fdsd9999afhgdfadss

gfdssafddfas

我依次判断listbox1的每一行是否包含9

然后将包含9的依次显示在listbox2上。

这个过程该怎么实现呢

代码

www.2cto.com

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim items = {"fad1saZZZffffdsfffdfg",

                     "fdsaafd999afdaffaf",

                     "fd3safdafdsa999fdssafd",

                     "fdsd9999afhgdfadss",

                     "gfdssafddfas"}

 

        Me.ListBox1.Items.AddRange(items)

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        For Each item As String In Me.ListBox1.Items

            If item.Contains("9") Then

                '输出

                Me.ListBox2.Items.Add(item)

            End If

        Next

    End Sub

摘自  Shine的圣天堂-〃敏〃