additem 添加属性

listcount总记录数

listindex索引值

Private Sub Form_Load()
List1.AddItem "广东省广州市"
List1.AddItem "广东省河源市"
List1.AddItem "广东省惠州市"
List1.ListIndex = 0
End Sub

Private Sub LeftAll_Click()
Dim i As Integer
  For i = 0 To List2.ListCount - 1
  List1.AddItem List2.List(i)
  Next
  List2.Clear
  List1.ListIndex = List1.NewIndex
  
End Sub

Private Sub LeftOne_Click()
Dim i As Integer
  If List2.ListCount = 0 Then Exit Sub
   List1.AddItem List2.Text
   i = List2.ListIndex
   List2.RemoveItem i
   List1.ListIndex = List1.NewIndex
    If List2.ListCount > 0 Then
    If i > List2.ListCount - 1 Then
    List2.ListIndex = i - 1
    Else
       List2.ListIndex = i
    End If
  End If
End Sub

Private Sub List1_dblclick()

RightOne_Click
End Sub

Private Sub List2_dblClick()
LeftOne_Click
End Sub

Private Sub RightOne_Click()
Dim i As Integer
If List1.ListCount = 0 Then Exit Sub
   List2.AddItem List1.Text
   i = List1.ListIndex
   List1.RemoveItem List1.ListIndex
   If List1.ListCount > 0 Then
   If i > List1.ListCount - 1 Then
   List1.ListIndex = i - 1
   Else
    List1.ListIndex = i
    End If
End If
List2.ListIndex = List2.NewIndex
End Sub
Private Sub RightALL_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
 List1.Clear
 List2.ListIndex = 0
End Sub

Private Sub Up_Click()
Dim Up As Integer
With List2
If .ListIndex < 0 Then Exit Sub
  Up = .ListIndex
  If Up = 0 Then Exit Sub '不能将第一个项目向上移动
  .AddItem .Text, Up - 1 '向上移动项目
  .RemoveItem Up + 1   '删除旧的项目
  .Selected(Up - 1) = True   '选择刚刚被移动的项目
  End With
End Sub
Private Sub Down_Click()
Dim Down As Integer
  With List2
  If .ListIndex < 0 Then Exit Sub
    Down = .ListIndex
    If Down = .ListCount - 1 Then Exit Sub  '不能将最后的项目向下移动
    .AddItem .Text, Down + 2  '向下移动项目
    .RemoveItem Down     '删除旧的项目
    .Selected(Down + 1) = True  '选择刚刚被移动的项目
    
  End With
    
End Sub

附有截图

先新建两个listbox一个命名为:list1和一个list2

和六个命令按钮,详细命名见上图即可。为左、右、全左、全右、上、下

VB LISTBOX属性的更多相关文章

  1. c#、vb 自动属性

    vb示例: Public Property Name() As String = "Bob" 等效于 Private _name As String = "Bob&quo ...

  2. VB默认属性、动态数组、Range对象的默认属性的一点不成熟的想法

    1.默认属性 VB6.0有默认属性的特性.当没有给对象指定具体的属性时,"默认属性"是VB6.0将使用的属性.在某些情形下,省略常用属性名,使代码更为精简. 因为CommandBu ...

  3. VB ListBox 添加横向滚动条

    Private Declare Function SendMessage Lib "user32 " Alias "SendMessageA" (ByVal h ...

  4. vb sendmessage 详解1

    SendMessage函数的常用消息及其应用(有点长,希望能对大家有所帮助)函数原型: Declare Function SendMessage Lib "user32" Alia ...

  5. listbox里面添加WrapPanel ,支持自适应换行

    listbox大家都会用,如果要让它支持换行操作还必须加上 ListBox.ItemsPanel ItemsPanelTemplate toolkit:WrapPanel/ /ItemsPanelTe ...

  6. listbox控件使用

    1. 属性列表: SelectionMode    组件中条目的选择类型,即多选(Multiple).单选(Single)    Rows             列表框中显示总共多少行    Sel ...

  7. VB如何连接访问数据库Access

    VB如何连接访问数据库Access 听语音 | 浏览:10675 | 更新:2015-05-05 11:26 | 标签:连接 access 1 2 3 4 5 6 7 分步阅读 VB即Visual B ...

  8. vba中ListBox控件的使用

    给ListBox添加内容 If CheckBox8 = True Then---------------------------checkbox控件被选中 For i = 0 To ListBox1. ...

  9. SendMessage函数的常用消息及其应用大全

    来源:http://www.360doc.com/content/09/0814/10/19147_4907488.shtml,非常全面的解释. 文本框控件通常用于输入和编辑文字.它属于标准 Wind ...

随机推荐

  1. 回顾下$.ajax()方法参数

    1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为String类型的参数,请求方式(post或get)默认为get.注意其他http请求方法,例如 ...

  2. PostgreSQL控制台以竖行显示

    \x select * from user; 这个和MySQL的有点区别,在查询之前使用\x进行显示的开启 注意:只需要用一次即可,以后的查询都是以竖行进行显示.

  3. js:深入prototype(上:内存分析)

    /**  * 下面演示了通过原型的创建方式,使用基于原型的创建能够将属性和方法  * 设置为Person专有的,不能通过window来调用.  * 原型是javascript中的一个特殊对象,当一个函 ...

  4. hint.css使用说明

    GitHub:http://liu12fei08fei.github.io/html/1hint.html hint.css使用说明 用途 快速实现tooltips提示样式 相关资源 官方网站GitH ...

  5. intrawebIW当作REST 服务端

    intraweb15 该版本支持HTTPS.SYS通信. IW当作REST 服务端使用: procedure TIWServerController.IWServerControllerBaseExe ...

  6. 【maven】排除maven中jar包依赖的解决过程 例子:spring cloud启动zipkin,报错maven依赖jar包冲突 Class path contains multiple SLF4J bindings.

    一直对于maven中解决jar包依赖问题的解决方法纠结不清: 下面这个例子可以说明一个很简单的解决方法: 项目启动报错: Connected to the target VM, address: '1 ...

  7. 使用开源库 SDWebImage 异步下载缓存图片(持续更新)

    source  https://github.com/rs/SDWebImage APIdoc  http://hackemist.com/SDWebImage/doc Asynchronous im ...

  8. Leader之重

    1:合理安排每个CASE并检查每个人每天的工作进度和质量: 这会让一个庞大的工作,或者看上不可能完成的任务,变成可完成的.   2:警惕对立情绪,并寻找交接者: 永远无法控制所有成员对你或者对团队对公 ...

  9. Gson全解析(下)-Gson性能分析

    前言 在之前的学习中,我们在Gson全解析(上)Gson使用的基础到分别运用了JsonSerializer和JsonDeserializer进行JSON和java实体类之间的相互转化. 在Gson全解 ...

  10. L'Hospital法则及其应用

      from: http://math.fudan.edu.cn/gdsx/XXYD.HTM