国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

VB中如何用List進(jìn)行選擇

2024-07-21 02:20:50
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
  • 本文來(lái)源于網(wǎng)頁(yè)設(shè)計(jì)愛(ài)好者web開(kāi)發(fā)社區(qū)http://www.html.org.cn收集整理,歡迎訪(fǎng)問(wèn)。
  • 提供
    單item函數(shù):
    cmddel_click
    cmdadd_click
    多item函數(shù):
    cmddelall_click
    cmdaddall_click
    ---------------------------------------------------------------------------------------------------------------------
    'option explicit

    'author:nyb
    'time:2002-04-05
    '傳入list1,list2,然后我們可以對(duì)list1,和list2中的item進(jìn)行處理.
    '*all areas of code where modifications are necessary
    '*to integrate this object with a project are documented
    'with comments denoted by note:.
    '*to locate these comments,search for ‘*note::.
    '****************************************************************************************

    public sub cmddelall_click(list1 as listbox, list2 as listbox) '<<
    '*purpose: delete all list2.item
    '*accept: list1 沒(méi)有用,list2處理對(duì)象
    for i = (list2.listcount - 1) to 0 step -1
    list2.removeitem i
    next i
    end sub
    public sub cmdadd2to1_click(list1 as listbox, list2 as listbox, list3 as listbox) '>>
    '*purpose: all item of list1 and list2 are inputed to list3
    '*accept: list1,list2
    for i = 0 to (list1.listcount - 1)
    list3.additem list1.list(i)
    next i
    for i = 0 to (list2.listcount - 1)
    list3.additem list2.list(i)
    next i
    end sub

    public sub cmdaddall_click(list1 as listbox, list2 as listbox, index as integer) '>>
    '*purpose: add all item of list1 inputed to list2.if item had been there, it won't be inputed
    '*accept: list1,list2
    if list2.listcount = 0 then
    for i = 0 to (list1.listcount - 1)
    list2.additem list1.list(i)
    next i
    else
    for i = 0 to (list1.listcount - 1)
    flag = checkselected(list1, list2, list1.list(i))
    if flag = "notbe" then list2.additem list1.list(i)
    next i
    end if
    end sub


    public sub cmddel_click(list1 as listbox, list2 as listbox) '<---
    '*purpose: the selected items of list2 are cleared
    '*accept: list1 沒(méi)有用,list2處理對(duì)象
    dim i as integer
    if list2.selcount > 0 then
    for i = (list2.listcount - 1) to 0 step -1
    if list2.selected(i) = true then list2.removeitem i
    next i
    end if
    end sub

    public sub cmdadd_click(list1 as listbox, list2 as listbox, index as integer) '--->
    '*purpose: the selected items of list1 is inputed into list2
    ' list2為空,list2又可以多選,那么items selected in list1 are inputed to list2
    ' list2不為空,list2又可以多選,那么先檢查item是否在list2中,如果在,那么就不添入list2
    ' list2設(shè)為單選,那么list2只添加list1中的的第一選中項(xiàng)
    '*accept: list1 選中的項(xiàng)目,list2為要加入的listbox
    dim i as integer
    dim flag as string

    if index > 0 then
    if list2.listcount >= 1 then
    if index = 2 then
    if list2.listcount >= 2 then
    if list1.multiselect = 0 then
    msgbox "只能選定兩期對(duì)比!", vbexclamation, "操作提示!"
    exit sub
    end if
    end if
    end if
    end if
    end if

    if list2.listcount = 0 and list2.multiselect = 2 then
    for i = 0 to (list1.listcount - 1)
    if list1.selected(i) = true then list2.additem list1.list(i)
    next i
    elseif list2.listcount > 0 and list2.multiselect = 2 then
    for i = 0 to (list1.listcount - 1)
    flag = checkselected(list1, list2, list1.list(i))
    if list1.selected(i) = true and flag = "notbe" then list2.additem list1.list(i)
    next i
    elseif list2.multiselect = 0 then
    call cmddelall_click(list1, list2)
    for i = 0 to (list1.listcount - 1)
    if list1.selected(i) = true then list2.additem list1.list(i)
    next i
    end if
    call clearselect(list1)
    end sub

    private function checkselected(list1 as listbox, list2 as listbox, cityitem as string) as string
    '*purpose: '檢查item是否已經(jīng)被添加,已添加則checkselected = "be"
    '*accept: list1 選中的項(xiàng)目,list2為要加入的listbox,cityitem為list1 中一個(gè)被選中的項(xiàng)目
    '*feedback: checkselected , "be" 表示這個(gè)item在list2中存在
    for i = (list2.listcount - 1) to 0 step -1
    if cityitem = list2.list(i) then
    checkselected = "be"
    exit for
    else: checkselected = "notbe"
    end if
    next i
    end function

    private sub clearselect(list1)
    '*purpose: clear list1's selected
    '*accept: list1 ,the list box to clear selected
    for i = 0 to list1.listcount - 1
    if list1.selected(i) = true then
    list1.selected(i) = false
    end if
    next i
    end sub




    發(fā)表評(píng)論 共有條評(píng)論
    用戶(hù)名: 密碼:
    驗(yàn)證碼: 匿名發(fā)表
    主站蜘蛛池模板: 金沙县| 克东县| 鲜城| 即墨市| 神木县| 华坪县| 哈巴河县| 宜良县| 福鼎市| 齐河县| 靖远县| 金坛市| 贵港市| 万盛区| 岗巴县| 泊头市| 依安县| 堆龙德庆县| 广州市| 泰顺县| 延边| 垦利县| 年辖:市辖区| 项城市| 新巴尔虎左旗| 台州市| 塔河县| 广东省| 柳州市| 安塞县| 东城区| 凤冈县| 永昌县| 邹平县| 黄浦区| 滦平县| 荥经县| 宁都县| 榆林市| 思茅市| 宣恩县|