**Example.** We introduce two Functions: ConvertMilesToKilometers, and ConvertKilometersToMiles. In each Function body, the argument is multiplied by a constant value and that result is returned from the Function.

**Note:** This provides a close approximation of your distance in the opposite unit.

**VB.NET program that converts miles and kilometers**
Module Module1
Function ConvertMilesToKilometers(ByVal miles As Double) As Double
Return miles * 1.609344
End Function
Function ConvertKilometersToMiles(ByVal kilometers As Double) As Double
Return kilometers * 0.621371192
End Function
Sub Main()
Dim milesValues() As Double = {200.0, 310.7}
For Each value As Double In milesValues
Console.WriteLine(*"{0} miles -> {1:0.0} km"*, value, ConvertMilesToKilometers(value))
Next
Dim kilometersValues() As Double = {321.9, 500.0}
For Each value As Double In kilometersValues
Console.WriteLine(*"{0} km -> {1:0.0} miles"*, value, ConvertKilometersToMiles(value))
Next
End Sub
End Module
**Output**
200 miles -> 321.9 km
310.7 miles -> 500.0 km
321.9 km -> 200.0 miles
500 km -> 310.7 miles

**Summary.** Numeric conversions, such as from miles to kilometers, are easily done in the VB.NET language. Typically, the Double type is good for these, as it retains more significant digits in a multiplication expression than does the Integer type.

**Finally:** For verification that these conversions are correct, please see the alternative version of this article.

C# Convert Miles