Figure 4 Point Class in Visual Basic .NET
กก
Imports System
Imports System.Data.SqlServer
Imports System.Data.SqlTypes
Imports System.Runtime.Serialization

<Serializable(), SqlUserDefinedType(Format.Native)> Public Class Point
    Implements INullable

    Private is_Null As Boolean 
    Private m_x As Decimal
    Private m_y As Decimal

    Public ReadOnly Property IsNull() As Boolean _
       Implements INullable.IsNull
        Get
            Return (is_Null)
        End Get
    End Property

    Public Overrides Function ToString() As String
        If Me.IsNull Then
            Return "NULL"
        Else
            Return Me.m_x & ":" & Me.m_y
        End If
    End Function

    Public Shared Function Parse(ByVal s As SqlString) As Point
        If s.IsNull Then
            Return Nothing
        Else
        'Parse input string here to separate out points
        Dim pt as new Point()
        Dim str as String = Convert.ToString(s)
        Dim xy() as String = str.Split(":")
        pt.x = xy(0)
        pt.y = xy(1)
            Return (pt)
        End If
    End Function

    Public Shared ReadOnly Property Null() As Point
        Get
            Dim pt As New Point
            pt.is_Null = True
            Return (pt)
        End Get
    End Property

    Public Property X() As Decimal
        Get
            Return (Me.m_x)
        End Get
        Set(ByVal Value As Decimal)
            m_x = Value
        End Set
    End Property

    Public Property Y() As Decimal
        Get
            Return (Me.m_y)
        End Get
        Set(ByVal Value As Decimal)
                m_y = Value
        End Set
    End Property

    Public Function DistanceTo (ByVal other AS Object) 
        As Decimal
        Dim pt2 As New Point
        Dim pt1 As Point
        pt1 = me
        Return System.Convert.ToDecimal(System.Math.Sqrt( _
                System.Convert.ToDouble( _
                (pt1.x - pt2.x) * (pt1.x - pt2.x) + 
                (pt1.y - pt2.y) * (pt1.y - pt2.y))))
    End Function                

End Class