A Console Application to convert between Celsius and Fahrenheit. Alternatively, you could use the c2f() and f2c() functions for other purposes
Module TempratureConverter
' Temprature converter. Celsius/Fahrenheit
' Jonesy44
' 28 Sept 09
' declare variables
Dim x As Double, con_type As String ' 0=c2f,1=f2c conversion
Sub Main()
' Main console application
Console.WriteLine("Temprature Converter (Celsius/Fahrenheit) by Jonesy44")
Go()
End Sub
Sub Go()
Console.WriteLine(vbCrLf & vbCrLf & "Would you like to convert to celsius[c] or to Fahrenheit[f]? [c/f]: ") : con_type = Console.ReadLine
Console.WriteLine("Enter the value to convert: ") : x = Console.ReadLine
If con_type = "f" Then : c2f(x)
ElseIf con_type = "c" Then : f2c(x)
End If
GoAgain()
End Sub
Sub GoAgain()
Console.Write(vbCrLf & "Another Conversion? [y/n]: ")
If Console.ReadLine = "y" Then : Go()
Else : End
End If
End Sub
Sub c2f(ByRef val As Double)
Console.Write(val & "°C is " & Math.Round(((9 * val) + 160) / 5, 2) & "°F")
End Sub
Sub f2c(ByRef val As Double)
Console.Write(val & "°F is " & Math.Round(5 * (val - 32) / 9, 2) & "°C")
End Sub
End Module