VB怎么给shape改变颜色

2024-11-07 21:17:06
推荐回答(5个)
回答1:

可以在属性窗口设置shape控件的BorderColor属性设置边框颜色,设置了FillStyle属性后,可以通过FillColor属性设置填充颜色。
如果代码设置,在某事件过程中输入语句:
Shape1.BorderColor = vbRed
Shape1.FillStyle = vbshapesolid
Shape1.FillColor = vbRed

回答2:

设置填充方式为实心,更改填充色。如:
Private Sub Command1_Click()
Shape1.FillStyle = 0
Shape1.FillColor = vbYellow
End Sub

回答3:

Private Sub Form_Load()
Shape1.BackStyle = 1
Shape1.BorderStyle = 0
Shape1.BackColor = vbRed
End Sub

回答4:

Private Sub Command1_Click()
Shape1.FillColor = RGB(255, 0, 0) '改为红色
End Sub

Private Sub Form_Load()
Shape1.FillStyle = 0
Shape1.FillColor = RGB(0, 0, 0) '黑色
End Sub

回答5:

'shape1,timer1
Private Sub Form_Load()
Timer1.Interval = 2000
Shape1.Shape = 3
Shape1.FillStyle = 0
Shape1.FillColor = RGB(0, 0, 255)
End Sub

Private Sub Timer1_Timer()
Static intColor As Integer
Select Case intColor
Case 0
Shape1.FillColor = RGB(255, 0, 0) '改为红色
Case 1
Shape1.FillColor = RGB(0, 255, 0) '改为绿色
Case 2
Shape1.FillColor = RGB(0, 0, 255) '改为蓝色
intColor = -1
End Select
intColor = intColor + 1
End Sub