Convert Metres to Feet and Inches
My offering for converting metric to imperial is below. This is based on metres and feet, however it is easy to scale up, just calculate the number of eighths in the desired distance.
vb.net Code:
Private Function MetresToFeet(ByVal Answer As Single) As String
Dim Fraction As String = ""
Dim Inches As Single
Dim Feet As Single
Const OneEighth As Single = 0.003175
'8 eighths in an inch
'96 eighths in a foot
Feet = Int(Answer / (96 * OneEighth))
Answer -= Feet * (96 * OneEighth)
Inches = Int(Answer / (8 * OneEighth))
Answer -= Inches * (8 * OneEighth)
Select Case Answer
Case Is >= 7 * OneEighth
Fraction = "⅞"
Case Is >= 6 * OneEighth
Fraction = "¾"
Case Is >= 6 * OneEighth
Fraction = "⅝"
Case Is >= 4 * OneEighth
Fraction = "½"
Case Is >= 3 * OneEighth
Fraction = "⅜"
Case Is >= 2 * OneEighth
Fraction = "¼"
Case Is >= OneEighth
Fraction = "⅛"
Case Else
Fraction = ""
End Select
Return Feet.ToString & "' " & Inches.ToString & Fraction & """"
End Function