vb中怎么设置每摁一下窗体变换一次颜色?

2024-11-02 17:28:39
推荐回答(2个)
回答1:

我之前纠结了很久怎么做到有规律地点击换颜色,刚才突然想到了,设置一个变量n
dim n as integer
private sub form1_load()
scale(0,0)-(20,20)
circle(10,10),2, vb red
end sub
private sub form1_click
n=n+1
if n mod 3=0 then form1.forecolor= vbred
if (n+1)mod 3=0 then form1.forecolor = vbblue
if (n+2)mod 3=0 then form1.forecolor = vbyellow
end sub

回答2:

Private Sub Form_Click()
Me.FillColor = IIf(Me.FillColor = vbYellow, vbGreen, IIf(Me.FillColor = vbRed, vbYellow, vbRed))
Me.Circle (10, 10), 2, Me.FillColor
End Sub

Private Sub Form_Load()
Me.Scale (0, 0)-(20, 20)
Me.FillStyle = 0
Me.AutoRedraw = True
Form_Click
End Sub