?? boat.vb
字號:
Public Class Boat
Private RegistrationNo As Integer
Private length As Integer
Private manufacture As String
Private year As Integer
Public Sub New()
RegistrationNo = 1
length = 150
manufacture = "第一造船廠"
year = 1982
End Sub
Public Sub New(ByVal R As Integer, ByVal l As Integer, ByVal m As String, ByVal y As Integer)
RegistrationNo = R
length = l
manufacture = m
year = y
End Sub
Public Property mRegistrationNo() As Integer
Get
Return RegistrationNo
End Get
Set(ByVal Value As Integer)
RegistrationNo = Value
End Set
End Property
Public Property mlength() As Integer
Get
Return length
End Get
Set(ByVal Value As Integer)
length = Value
End Set
End Property
Public Property mManufacture() As String
Get
Return manufacture
End Get
Set(ByVal Value As String)
manufacture = Value
End Set
End Property
Public Property mYear() As Integer
Get
Return year
End Get
Set(ByVal Value As Integer)
year = Value
End Set
End Property
Public Function toallstring() As String
Dim str As String
str = String.Format("船的注冊號={0}", mRegistrationNo) & vbNewLine
str += String.Format("船的長度={0}", mlength) & vbNewLine
str += String.Format("船的制造商={0}", mManufacture) & vbNewLine
str += String.Format("船的生產年代={0}", mYear) & vbNewLine
Return str
End Function
Class Test
Shared Sub Main()
Dim output As String
Dim R1 As Boat = New Boat
output = "r1:" + vbNewLine
output += R1.toallstring()
MessageBox.Show(output, "輸出結果")
Dim R2 As Boat = New Boat
output = "r2:" + vbNewLine
output += R2.toallstring()
MessageBox.Show(output, "輸出結果")
Dim R3 As Boat = New Boat
output = "r3:" + vbNewLine
output += R3.toallstring()
MessageBox.Show(output, "輸出結果")
End Sub
End Class
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -