s8塞恩怎么玩:vb高手来帮手看看我哪里错了

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/27 15:57:12
Private Sub trapmos(object1 As Object, button As Integer, shift As Integer, x As Single, y As Single)
Static oldctl As Object
Static oldclr As Long

If nofcs Then
Set oldctl = object1
oldclr = object1.BackColor

object1.BackColor = RGB(0, 0, 255)
nofcs = False
evt(0) = "mousefocus at" & (object1.Name)
ElseIf oldctl.Name <> object1.Name Then
oldctl.BackColor = oldclr
Set oldctl = object1
oldclr = object1.BackColor
object1.BackColor = RGB(0, 0, 255)
evt(0) = "mousefocus at" & (object1.Name)
End If

evt(1) = "botton=" & Str(button) & " shift=" & Str(shift)
evt(2) = "x=" & Str(x) & "y=" & Str(y)
End Sub

nofcs的初值为true,编译时出现对象变量或with块变量未设置,我想应该是elseif 那里的oldctl,但nofcs为真,不是应该先做第一个if吗,做了第一个if,oldctl就有处值拉,那为什么错了`