Programming Fundamentals/Functions/VB.NET: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Creating |
(No difference)
|
Revision as of 17:37, 22 January 2017
subroutines.vb
' This program asks the user for a Fahrenheit temperature,
' converts the given temperature to Celsius,
' and displays the results.
Public Module Main
Sub Main
Dim F As Double
Dim C As Double
F = GetF()
C = CalculateC(F)
DisplayResult(F, C)
End Sub
Function GetF() As Double
Dim Input As String
Dim F As Double
Console.WriteLine("Enter Fahrenheit temperature:")
Input = Console.ReadLine()
F = Convert.ToDouble(Input)
Return F
End Function
Function CalculateC(F As Double) As Double
Dim C As Double
C = (F - 32) * 5 / 9
Return C
End Function
Sub DisplayResult(F As Double, C As Double)
Console.WriteLine(F.ToString() + "° Fahrenheit is " + C.ToString() + "° Celsius")
End Sub
End Module
Try It
Copy and paste the code above into one of the following free online development environments or use your own VB.NET compiler / interpreter / IDE.