📄 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 + -