Visual Basic .NET Example

This section takes the ball class from Chapter 2 and compiles it as an object that will be available to the ASP.NET application.

Here is the ball class.

ball_vb.vb
Namespace Peter.Toybox 
    Public Class Ball 
        Private _Color as String 
        Private _Motion as String 

        Public Sub New() 
            _Motion = "Still" 
        End Sub 

        Public Property Color as String 
            Get 
                Return _Color 
            End Get 
            Set 
                _Color = value 
            End Set 
        End Property 

        Public ReadOnly Property Motion as String 
            Get 
                Return _Motion 
            End Get 
        End Property 

        Public Sub Roll() 
            _Motion="Rolling" 
        End Sub 
    End Class 
End Namespace 

Enter this source example into your favorite text editor and save this as ball_vb.vb.

After you have the file saved, you can try to compile it. On my machine, the files are saved ...

Get ASP.NET for Web Designers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.