當把變數宣告為類別,在變數後打上點符號,VB 會自動列出一堆東西可以選擇,這些東西就是該類別的成員:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Class Vehicle
Public SkinColor As Color
End Class
End Class
●該類別的變數就多了 SkinColor 可被使用:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Vehicle = New Vehicle
x.SkinColor = Color.Olive
Me.BackColor = x.SkinColor
End Sub
Class Vehicle
Public SkinColor As Color
End Class
End Class
●執行後按下 Button1 後的結果:
沒有留言:
張貼留言