unit.vb

Public Class Unit
    Private meter As Double
    
    Public Sub New()
        meter = 0
    End Sub
    
    Public Sub FromMilliMeter(ByVal val As Double)
        meter = val * 0.001
    End Sub
    
    Public Sub FromMeter(ByVal val As Double)
        meter = val
    End Sub
    
    Public Sub FromKiloMeter(ByVal val As Double)
        meter = val * 1000
    End Sub
    
    Public Sub FromInch(ByVal val As Double)
        meter = val * 0.0254
    End Sub
    
    Public Sub FromYard(ByVal val As Double)
        meter = val * 0.9144
    End Sub
    
    Public Function ToMilliMeter() As Double
        Return meter * 1000
    End Function
    
    Public Function ToMeter() As Double
        Return meter
    End Function
    
    Public Function ToKiloMeter() As Double
        Return meter * 0.001
    End Function
    
    Public Function ToInch() As Double
        Return meter * 39.36996
    End Function
    
    Public Function ToYard() As Double
        Return meter * 1.09361
    End Function
End Class