Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert Fahrenheit to Celsius with VBA
#1
Example:

Sub ConvertToFahrenheit()
    Dim fahrenheitTemp As Double
    Dim celsiusTemp As Double

    fahrenheitTemp = 68
    celsiusTemp = (fahrenheitTemp - 32) * 5 / 9

    MsgBox fahrenheitTemp & " degrees Fahrenheit is equal to " & celsiusTemp & " degrees Celsius."
End Sub

Explanation:

This code defines a subroutine named ConvertToFahrenheit. 
It declares two variables fahrenheitTemp and celsiusTemp to store temperatures in Fahrenheit and Celsius, respectively. 
It sets the value of fahrenheitTemp to 68. 
The temperature in Fahrenheit is converted to Celsius using the formula (Fahrenheit - 32) * 5 / 9. 
The converted temperature is then displayed in a message box.

The formula (Fahrenheit - 32) * 5 / 9 is used to convert temperatures from Fahrenheit to Celsius. 
The MsgBox function displays the converted temperature in a message box.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Messages In This Thread
Convert Fahrenheit to Celsius with VBA - by Qomplainerz - 07-27-2023, 07:51 AM

Forum Jump:


Users browsing this thread: 5 Guest(s)