Subject: Chp. 5 help on pg 77
Posted By: amber.wray Post Date: 10/3/2008 9:16:40 AM
I am a 100% new beginner to this.

the Try it out on Pg 77, I have typed it in exactly as in the book and it doesn't like the chckCelsiusToFahrenheit after the Result in the If Statement.  I've tried declaring the variable, because it says it's not declared, however, when I do that, it says it's also invalid.  Any help is appreciated.

Here's the code...


    Private Sub btnconvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnconvert.Click
        Dim result As Decimal
        If chkCelsiusToFahrenheit.CheckState = CheckState.Checked Then
            result = CelsiusToFahrenheit(CType(txtDegrees.Text, Decimal))

        Else

            result = FahrenheitToCelsius(CType(txtDegrees.Text, Decimal))
        End If
        txtDegrees.Text = result.ToString

    End Sub
        
    Private Function FahrenheitToCelsius(ByVal FDegrees As Decimal) As Decimal
        Dim CDegrees As Double

        CDegrees = (5 / 9) * (FDegrees - 32)
        Return CType(CDegrees, Decimal)
    End Function
End Class

Go to topic 74360

Return to index page 1