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



写了一个简单的程序,有点地方不完善应该怎么改


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


写了一个简单的程序,有点地方不完善应该怎么改
发表于:2008-01-18 13:46:48 楼主
label中的数字闪的太快了,怎样让他闪动慢点


dim   bstop   as   boolean
dim   n(1   to   20),   i,   q

private   sub   command1_click()
        dim   j
        dim   str   as   string
        command1.visible   =   false
       
        randomize   timer
        str   =   ""
        open   "c:\vbt.txt"   for   output   as   #1
        while   j   <   2
                q   =   int(rnd(1)   *   20   +   1)
                label1.caption   =   q:   doevents
                if   n(q)   =   0   and   bstop   =   true   then
                        str   =   str   &   q   &   chr(13)   &   chr(10)
                        n(q)   =   1
                        j   =   j   +   1
                        bstop   =   false
                end   if
        wend
     
        if   str   <>   ""   then
                print   #1,   str
        end   if
        close   #1
end   sub

private   sub   command2_click()
bstop   =   true
end   sub

private   sub   form_load()
for   i   =   1   to   20
n(i)   =   0
next
j   =   0
bstop   =   false
end   sub


发表于:2008-01-18 13:54:531楼 得分:0
如果只按一次停止按钮就跑完这个循环应该怎么改
发表于:2008-01-18 14:02:342楼 得分:0
option   explicit
private   declare   sub   sleep   lib   "kernel32"   (byval   dwmilliseconds   as   long)

dim   bstop           as   boolean
dim   n(1   to   20),   i,   j,   q

private   sub   command1_click()
                'dim   j
                dim   str           as   string
                command1.visible   =   false
               
                randomize   timer
                str   =   ""
                open   "c:\vbt.txt"   for   output   as   #1
                while   j   <   2
                                q   =   int(rnd(1)   *   20   +   1)
                                label1.caption   =   q:               doevents:   sleep   500
                                if   n(q)   =   0   and   bstop   =   true   then
                                                str   =   str   &   q   &   chr(13)   &   chr(10)
                                                n(q)   =   1
                                                j   =   j   +   1
                                                bstop   =   false
                                end   if
                wend
           
                if   str   <>   ""   then
                                print   #1,   str
                end   if
                close   #1
end   sub

private   sub   command2_click()
bstop   =   true
end   sub

private   sub   form_load()
for   i   =   1   to   20
n(i)   =   0
next
j   =   0
bstop   =   false
end   sub
发表于:2008-01-18 15:46:083楼 得分:0
option       explicit  
private       declare       sub       sleep       lib       "kernel32"       (byval       dwmilliseconds       as       long)  

dim       bstop                       as       boolean  
dim       n(1       to       20),       i,       j,       q  

private       sub       command1_click()  
                                'dim       j  
                                dim       str                       as       string  
                                command1.visible       =       false  
                               
                                randomize       timer  
                                str       =       ""  
                                open       "c:\vbt.txt"       for       output       as       #1  
                                while       j       <       2   and   bstop   =   false
                                                                q       =       int(rnd(1)       *       20       +       1)  
                                                                label1.caption       =       q:                               doevents:       sleep       500  
                                                                if       n(q)       =       0       and       bstop       =       true       then  
                                                                                                str       =       str       &       q       &       chr(13)       &       chr(10)  
                                                                                                n(q)       =       1  
                                                                                                j       =       j       +       1  
                                                                                                bstop       =       false  
                                                                end       if  
                                wend  
                       
                                if       str       <>       ""       then  
                                                                print       #1,       str  
                                end       if  
                                close       #1  
end       sub  

private       sub       command2_click()  
bstop       =       true  
end       sub  

private       sub       form_load()  
for       i       =       1       to       20  
n(i)       =       0  
next  
j       =       0  
bstop       =       false  
end       sub  


不知道按停止按钮究竟跑完这个循环是不是这个意思了...


快速检索

最新资讯
热门点击