Private Sub Command1_Click()If Text1.Text = "" Then
MsgBox "xxxx"
End If
For i = 1 To List1.ListCount - 1
If List1.Text = Text1.Text Then
MsgBox "xxxxx"
End If
Exit Sub
Next
List1.AddItem Text1.Text
End SubPrivate Sub Form_Load()
List1.AddItem 1
List1.AddItem 2
List1.AddItem 3
List1.AddItem 4
List1.AddItem 5End Sub

解决方案 »

  1.   


    Private Sub Command1_Click()
        If Trim(Text1.Text) = "" Then
            MsgBox "输入不能为空!"
            Exit Sub
        Else
            Dim i As Integer
            Dim Equ As Boolean
            
            For i = 0 To List1.ListCount - 1
                List1.ListIndex = i
                If Text1.Text = List1.Text Then
                   MsgBox "输入相同!"
                   Text1.Text = ""
                   Exit Sub
                End If
            Next
            List1.AddItem Text1.Text
        End If
    End Sub
      

  2.   

    不好意思,上面的 Dim Equ As Boolean  没有用的,去掉好了