您的位置:程序门 -> vb -> 基础类



困扰多时的vb筛选问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


困扰多时的vb筛选问题
发表于:2008-01-13 13:59:15 楼主
有n个数字,如果我输入其中的m(m <=n)个,让程序输出剩余部分,用vb应该怎么写?热心大虾帮帮忙啦!
功力不行,搞了很久,没有搞出来。
发表于:2008-01-13 14:44:191楼 得分:0
把它们存在数组中,然后再数组中找到你输入的数字,取得数组的下标,
然后取得大于等于此下标的数组的值就可以了。
发表于:2008-01-13 14:52:282楼 得分:0
能用vba吗?在excel中一下就出来了。
发表于:2008-01-13 15:08:203楼 得分:0
具体的代码有吗?
发表于:2008-01-14 18:13:014楼 得分:0
'a   (m),   b(n)
sub   aaa()
        dim   i   as   integer,   s   as   variant
        s   =   " ¦"   &   join(b,   " ¦")   &   " ¦"
        for   i   =   0   to   m
                s   =   replace(s,   " ¦"   &   a(i)   &   " ¦",   " ¦")
        next   i
        s   =   split(mid(s,   2,   len(c)   -   2),   " ¦")
end   sub
发表于:2008-01-15 09:32:545楼 得分:0
简单:用   2   个   listbox   (visible   =   false):
private   declare   function   sendmessagebystring   lib   _
"user32"   alias   "sendmessagea"   (byval   hwnd   as   long,   _
byval   wmsg   as   long,   byval   wparam   as   long,   _
byval   lparam   as   string)   as   long

private   const   lb_findstringexact   =   &h1a2         '在   listbox   中精确查找

private   const   n   as   integer   =   100
dim   i   as   integer,   m   as   integer

private   sub   form_load()
    for   i   =   1   to   n
        list1.additem   cstr(i)
    next   i
end   sub

private   command1_click()   '清除输入
    list2.clear
end   sub

private   command2_click()   '输入数字。如果此按钮设置   default   =   true,   textbox   中回车完成输入
    list2.additem   text1.text
end   sub

private   command1_click()   '输出剩余
    for   i   =   0   to   list1.listcount   -   1
        if   sendmessagebystring(list2.hwnd,   lb_findstringexact,   -1,   list1.list(i))   >   -1   then
            debug.print   list1.list(i)
        end   if
    next   i
end   sub


快速检索

最新资讯
热门点击