lundi 9 novembre 2020

how to code for this program in visual basic?

Develop a VISUAL BASIC program which allows the user to enter two readings in the range 0 to 10. The readings are for temperature inside side a house and outside a house and should be captured using text boxes. There is should be a button called display which , when pressed, the program extracts these values to respective variables and determines the lower of the two readings. The lower temperature reading is then used to display a message indicating the action to be performed based on the following table (Message should be displayed in a Message Box):

Lower Temperature Message for action to be taken 7 or higher Increase heat 5 or higher, but less than 7 Wait for 5 minutes then increase heat 2 or higher, but less than 5 Wait for 10 minutes then increase heat
Below 2 Decrease heat

Public Class Form1
    Dim intTemperature As Integer
    Dim strMessage As String
    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        
        Select Case intTemperature
            Case Is >= 7
                strMessage = "Increase heat"
            Case Is >= 5
                strMessage = "Wait for 5 mins then increase heat"
            Case Is >= 2
                strMessage = "Wait for 10 mins then increase heat"
            Case Else
                strMessage = "Decrease heat"

        End Select
        MsgBox(strMessage)
    End Sub
End Class

Aucun commentaire:

Enregistrer un commentaire