time控件的卡顿问题
用来检测物体的灰度值的代码,为什么用久了会卡[code][/Private Sub Timer1_Timer()
Dim h As Long, dc As Long
Dim Xa As Long, Xb As Long, Xc As Long, Xd As Long, Xe As Long
Dim Ra As Byte, Ga As Byte, Ba As Byte, Rb As Byte, Gb As Byte, Bb As Byte, Rc As Byte, Gc As Byte, Bc As Byte, Rd As Byte, Gd As Byte, Bd As Byte, Re As Byte, Ge As Byte, Be As Byte
dc = GetDC(0)
Xa = GetPixel(dc, heng, zong)
Ra = (Xa Mod 256) \ 16
Ga = (Xa Mod 65536) \ 256
Ba = (Xa Mod 16777216) \ 65536
ReleaseDC dc, 0
Na = Ra / 3 + Ga / 3 + Ba / 3
Za = Int(Abs(Na - Ca))
Xb = GetPixel(dc, heng - 16, zong)
Rb = (Xb Mod 256) \ 16
Gb = (Xb Mod 65536) \ 256
Bb = (Xb Mod 16777216) \ 65536
ReleaseDC dc, 0
Nb = Ra / 3 + Ga / 3 + Ba / 3
Zb = Int(Abs(Nb - Cb))
Xc = GetPixel(dc, heng + 16, zong)
Rc = (Xc Mod 256) \ 16
Gc = (Xc Mod 65536) \ 256
Bc = (Xc Mod 16777216) \ 65536
ReleaseDC dc, 0
Nc = Rc / 3 + Gc / 3 + Bc / 3
Zc = Int(Abs(Nc - Cc))
Xd = GetPixel(dc, heng + 8, zong)
Rd = (Xd Mod 256) \ 16
Gd = (Xd Mod 65536) \ 256
Bd = (Xd Mod 16777216) \ 65536
ReleaseDC dc, 0
Nd = Rd / 3 + Gd / 3 + Bd / 3
Zd = Int(Abs(Nd - Cd))
Xe = GetPixel(dc, heng - 8, zong)
Re = (Xc Mod 256) \ 16
Ge = (Xc Mod 65536) \ 256
Be = (Xc Mod 16777216) \ 65536
ReleaseDC dc, 0
Ne = Re / 3 + Ge / 3 + Be / 3
Ze = Int(Abs(Ne - Ce))
Text5.Text = Za & "*" & Zb & "*" & Zc & "*" & Zd & "*" & Ze
If Za > 25 Or Zb > 25 Or Zc > 25 Or Zc > 25 Or Zc > 25 Then
Sleep (50)
Else
Exit Sub
End If
If Za > 25 Or Zb > 25 Or Zc > 25 Or Zc > 25 Or Zc > 25 Then
M = M + 1
Text1.Text = M & "辆"
T1 = GetTickCount()
DoEvents
Sleep (50)
Else
Exit Sub
End If
Timer2.Enabled = True
DoEvents
Timer1.Enabled = False
End Subcode]