推 dontblame:查一下 物件陣列 的寫法吧 12/22 17:17
第一次寫vb,請大大幫我看一下,有什麼觀念須要注意....
程式主要是在寫 mouse點選shape,shape就會改變成text1~3的RGB色碼
rgb色碼可以自己設
有個地方想問一下.
shape1這邊
如果有shape有 100個 , 那.....if不是就要100次???
是不是有陣列的寫法可以縮短行數??
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X > Shape1.Left And X < Shape1.Left + Shape1.Height And Y > Shape1.Top And Y < Shape1.Top + Shape1.Height Then
Shape1.BackColor = Color
End If
If X > Shape2.Left And X < Shape2.Left + Shape2.Height And Y > Shape2.Top And Y < Shape2.Top + Shape2.Height Then
Shape2.BackColor = Color
End If
If X > Shape3.Left And X < Shape3.Left + Shape3.Height And Y > Shape3.Top And Y < Shape3.Top + Shape3.Height Then
Shape3.BackColor = Color
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Color = RGB(Text1.Text, Text2.Text, Text3.Text)
Shape129.BackColor = Color
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
Color = RGB(Text1.Text, Text2.Text, Text3.Text)
Shape129.BackColor = Color
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
Color = RGB(Text1.Text, Text2.Text, Text3.Text)
Shape129.BackColor = Color
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.12.186
※ 編輯: CuckooBoy 來自: 123.195.12.186 (12/22 14:45)