sailboat.vb

来自「学习vb过程中老师讲过的所有案例!还有课程设计」· VB 代码 · 共 84 行

VB
84
字号
Public Class sailboat
    Inherits Boat
    Private keeldepth As Integer
    Private none As String
    Private number As Integer
    Public Sub New(ByVal k As Integer, ByVal no As String, ByVal n As Integer)
        keeldepth = k
        none = no
        number = n
    End Sub
    Public Property mkeeldepth() As Integer
        Get
            Return keeldepth
        End Get
        Set(ByVal Value As Integer)
            keeldepth = Value
        End Set
    End Property
    Public Property mnone() As String
        Get
            Return none
        End Get
        Set(ByVal Value As String)
            none = Value
        End Set
    End Property
    Public Property mnumber() As Integer
        Get
            Return number
        End Get
        Set(ByVal Value As Integer)
            number = Value
        End Set
    End Property
    Public Sub New()

    End Sub
    Public Function toallstring1() 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
        str += String.Format("龙骨={0}", mkeeldepth) & vbNewLine
        str += String.Format("帆船编号={0}", mnumber) & vbNewLine
        str += String.Format("马达类型={0}", mnone) & vbNewLine

        Return str

    End Function
    Class Test1

        Shared Sub Main()

            Dim output As String

            Dim R1 As sailboat = New sailboat
            output = "r1:" + vbNewLine
            output += R1.toallstring()
            MessageBox.Show(output, "输出结果")


            Dim R2 As sailboat = New sailboat
            output = "r2:" + vbNewLine
            output += R2.toallstring()
            MessageBox.Show(output, "输出结果")


            Dim R3 As sailboat = New sailboat
            output = "r3:" + vbNewLine
            output += R3.toallstring()
            MessageBox.Show(output, "输出结果")

        End Sub

    End Class
End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?