VB创建多线程应用程序(二)
源代码如下:
形式的代码:
Option Explicit
' Start
Private子命令1 _ Click()
On Error Resume Next[/br][/br With my thread left
。“初始化fillleft的地址”将过程地址传递给线程
。thread enabled = true
end with
with my thread right
。初始化Fillright的地址
。thread enabled = True
End With
With myThreadbottom
。初始化Fillbottom的地址[/br/ ]。thread enabled = true
end with
msgbox "多线程正在运行...看看画框控制的变色效果!”,64," information"
'终止线程运行
set my thread left = nothing
set my thread right = nothing
set my thread bottom = nothing
' End
私有子命令2 _ click ()
代码在end sub
模块中:
选项显式
计时API
私有声明函数show
End Sub
Public Sub fill left()
Static Bkgcolor As Long
Dim Long tick As Long,Long counter As Long
On Error Resume Next
For Long counter = 0到3000
do events
Bkgcolor = Long counter Mod 256
1 . picture 1 . back color = RGB(Bkgcolor,0,0)
终止当前线程,下同
end sub
public sub fill right()
static bkg color As Long
dim Long stickvlue As Long,Long counter As Long
On Error Resume Next
For Long counter = 0到3000
do events
bkg color = Long counter Mod 256
form 1 . Picture2.BackColor = RGB(0,Bkgcolor,0)
0条评论