My turn. Here's a function that converts centigrade to celsius:
Discuss and try and outdo, but hold any thanks until 2029 so that we can revisit this then.
Code:
Public Function to_Celsius(ByVal in_Centigrade As Double) As Double
' converts Centigrade temperature to Celsius
Dim ret As Double ' return value
Dim int_Counter As Integer ' counter variable for looping to calculate Celsius value
Dim int_CounterMax As Integer ' maximum value of Counter for looping
Dim int_Decimal As String ' determines where decimal point is in in_Centigrade
ret = 0
' default return value
int_CounterMax = Int(Abs(in_Centigrade))
' gets positive integer part of Centigrade so can loop and get Celsius
int_Decimal = InStr(in_Centigrade, ".")
If int_Decimal > 0 Then
' Centigrade has decimal value, will extract it to return value
ret = Mid(in_Centigrade, int_Decimal) * 1
End If
If (in_Centigrade < 0) Then
' submitted value is less than 0, will compute Celsius for it
For int_Counter = 1 To int_CounterMax
ret = ret + 1
Next
ret = ret * -1
End If
If (in_Centigrade > 1) Then
' submitted value is more than 1, will compute Celsius for it
int_Counter = 2 * int_CounterMax
Do While int_Counter > int_CounterMax
ret = ret + 1
int_Counter = int_Counter - 1
Loop
End If
to_Celsius = ret
End Function
Discuss and try and outdo, but hold any thanks until 2029 so that we can revisit this then.