请教大家:往listbox添加、删除、清空、上移一位、下移一位的代码?(通过按钮或菜单点击)
解决方案 »
- VB,VB,VB,VB,VB,VB,VB,VB,VB,VB···
- 求助:access中如何通过VBA,创建一个查询,并把指定的SQL语句复制进这个查询
- 急,VB中如何实现PC一次传2个字节给单片机?
- 怎样使用Document对象?
- active skins 4.3 显示不了绑定imagelist的toolbar中的图象,怎么办?
- 高手指教:怎样移动Line控件,line有没有句柄呢?
- 网络蚂蚁的下载机制是...
- listview空间问题 ? 谢谢大家!
- 图标显示的问题!
- 请问在win2000和nt中如何关机而有不会出现“现在可以关机的信息”直接断电源?谢了问题解决了会加分.
- 菜鸟求助:替换问题!
- 用FLASH.OCX控件,怎样在其上单击鼠标停止,或暂停?
'添加
List1.AddItem Text1.Text
End SubPrivate Sub Command2_Click()
'删除
If (List1.ListIndex > -1) Then
Call List1.RemoveItem(List1.ListIndex)
End If
End SubPrivate Sub Command3_Click()
'下移
Dim x, x1
If (List1.ListIndex > 0) Then
x1 = List1.List(List1.ListIndex)
x = List1.ListIndex
Call List1.RemoveItem(List1.ListIndex)
List1.AddItem x1, x - 1
End If
End SubPrivate Sub Command4_Click()
'上移
Dim x, x1
If ((List1.ListIndex < List1.ListCount - 1) And (List1.ListIndex > -1)) Then
x1 = List1.List(List1.ListIndex)
x = List1.ListIndex
Call List1.RemoveItem(List1.ListIndex)
List1.AddItem x1, x + 1
End If
End Sub
List1.AddItem "hello world"
2、List1.Clear
要在代码里写,就不能在listbox里写,然后读取么?谢谢
Private Sub Command5_Click()
List1.ClearEnd Sub
'添加
List1.AddItem "要添加的字符串"
End Sub
Dim s
s = InputBox("请输入添加的内容")
If (s <> "") Then
List1.AddItem s
End If
End Sub
Private Sub Command1_Click()
'添加
Dim a As String
a = InputBox("输入数据", "输入")
List1.AddItem a
End Sub
其它得原理相同:)
顺便问“java初学者”,你是dujiaxin吗?