代码,vb中,从列表框中删除文本框里输入的内容

[复制链接]
查看11 | 回复3 | 2010-6-2 11:50:47 | 显示全部楼层 |阅读模式
Private Sub Form_KeyDown(KeyCode As Integer, _

Shift As Integer)

If Chr(KeyCode) = "A" Then

Text1.Text = InputBox("请输入要添加的项目")

List1.AddItem Text1.Text

End If



If Chr(KeyCode) = "D" Then

Text1.Text = InputBox("请输入要删除的项目")

For i = 0 To i

If List1.List(i) = i + 1 Then

List1.RemoveItem Text1.Text


End If
Next i
End If
End Sub添加可以,但删除就行不通了?哪里有错?请指点一下~~~

回复

使用道具 举报

千问 | 2010-6-2 11:50:47 | 显示全部楼层
If Chr(KeyCode) = "D" Then
Text1.Text = InputBox("请输入要删除的项目")
For i = 0 To i
If List1.List(i) = Text1.Text Then
List1.RemoveItem(i)
End If Next i End If试下这个
回复

使用道具 举报

千问 | 2010-6-2 11:50:47 | 显示全部楼层
RemoveItem只能使用list的下标要改成list.removeitem i
回复

使用道具 举报

千问 | 2010-6-2 11:50:47 | 显示全部楼层
List1.RemoveItem Text1.TextRemoveItem的参数不是Text值 而是List1中Item的序号
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行