数据库(拷贝或移动列表框或组合框中的内容) |
|
www.nanhushi.com 佚名 不详 |
在做数据库程序时,通常会要求用户将数据从一个列表框移动到别一个列表框中。下面的子程序可以让你轻松实现这一功能。同时还提供参数,指定操作是移动数据(不保留原数据),还是拷贝数据(保留数据的副本在原列表框或组合框中);并且还可以选择是全部移动或拷贝数据,还是只移动或拷贝用户选定的部分。
参数 值 说明 fromctl 源列表框或组合框名 源列表框或组合框 toctl 目的列表框或组合框名 目的列表框或组合框 strmode 可选参数,默认情况下只拷贝 选中的项目 - 移动选中的项目 all 拷贝所有的项目,不需选中 -all 移动所有的项目,不需选中
源程序如下:
public sub copycombolist(fromctl as control, toctl as control, optional strmode as string)
on error resume next
dim intn as integer
screen.mousepointer = vbhourglass
if strmode <> "" then strmode = ucase(strmode) end if
with fromctl
if typename(fromctl) = "listbox" then for intn = .listcount - 1 to 0 step -1 if .selected(intn) or instr(strmode, "all") then toctl.additem .list(intn) toctl.itemdata(toctl.newindex) = .itemdata(intn) if instr(strmode, "-") = 1 then .removeitem (intn) end if next else for intn = .listcount - 1 to 0 step -1 toctl.additem .list(intn) toctl.itemdata(toctl.newindex) = .itemdata(intn) if instr(strmode, "-") = 1 then .removeitem (intn) next end if end with
screen.mousepointer = vbdefault
end sub
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: VB源码推荐:一个操作Ini文件的类 下一篇文章: VB中声明和使用API函数 |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|