关于VB的listbox控件的使用,救命啊,调不出来啊,
我想实现选中一些list2的项一次添加到list1中,预期效果是:1.若出现list1中已经添加了list2中有选中的项目,则出现提示窗口,2.list2中没有被选中的项...
我想实现选中一些list2的项一次添加到list1中,预期效果是:
1.若出现list1中已经添加了list2中有选中的项目,则出现提示窗口,
2.list2中没有被选中的项目则可以继续添加,
3.如果没有选中要添加的项目却点击了添加按钮,则出现提示窗口。
请各位大侠,大虾们,帮帮忙,感激涕零啊,,下面贴出图片和我的错误代码:(实在改不下去了)::
Private Sub Command1_Click()
Dim a As Integer, i As Integer,
' For i = 0 To List2.ListCount - 1
If List2.Selected(i) = True Then
Call checkData
' a = a + 1
End If
' Next i
' If a = 0 Then
' MsgBox "请在右边的文本框中选择项目", , "信息提示"
' Exit Sub
' End If
End Sub
Private Sub checkData()
Dim s As String, i As Integer
If List1.ListCount > 0 Then
For i = 0 To List1.ListCount - 1
If List2.List(i) = List1.List(i) Then
MsgBox "已经选过了。", vbOKCancel, "提示"
Exit For
End If
Next i
Else
For i = 0 To List2.ListCount - 1
If List2.Selected(i) = True Then
List1.AddItem List2.List(i)
End If
Next i
End If
End Sub 展开
1.若出现list1中已经添加了list2中有选中的项目,则出现提示窗口,
2.list2中没有被选中的项目则可以继续添加,
3.如果没有选中要添加的项目却点击了添加按钮,则出现提示窗口。
请各位大侠,大虾们,帮帮忙,感激涕零啊,,下面贴出图片和我的错误代码:(实在改不下去了)::
Private Sub Command1_Click()
Dim a As Integer, i As Integer,
' For i = 0 To List2.ListCount - 1
If List2.Selected(i) = True Then
Call checkData
' a = a + 1
End If
' Next i
' If a = 0 Then
' MsgBox "请在右边的文本框中选择项目", , "信息提示"
' Exit Sub
' End If
End Sub
Private Sub checkData()
Dim s As String, i As Integer
If List1.ListCount > 0 Then
For i = 0 To List1.ListCount - 1
If List2.List(i) = List1.List(i) Then
MsgBox "已经选过了。", vbOKCancel, "提示"
Exit For
End If
Next i
Else
For i = 0 To List2.ListCount - 1
If List2.Selected(i) = True Then
List1.AddItem List2.List(i)
End If
Next i
End If
End Sub 展开
展开全部
Private Sub Command1_Click()
Dim a As Integer, i As Integer,
For i = 0 To List2.ListCount - 1
If List2.Selected(i) Then
For j = 0 To List1.ListCount - 1
If List2.List(i) = List1.List(j) Then
MsgBox List2.List(i) & "已经选过了"
Exit For
End If
Next j
If j = List1.ListCount Then List1.AddItem List2.List(i)
a = a + 1
End If
Next i
If a = 0 Then MsgBox "请在右边的文本框中选择项目"
End Sub
Dim a As Integer, i As Integer,
For i = 0 To List2.ListCount - 1
If List2.Selected(i) Then
For j = 0 To List1.ListCount - 1
If List2.List(i) = List1.List(j) Then
MsgBox List2.List(i) & "已经选过了"
Exit For
End If
Next j
If j = List1.ListCount Then List1.AddItem List2.List(i)
a = a + 1
End If
Next i
If a = 0 Then MsgBox "请在右边的文本框中选择项目"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询