I am studying VB.NET in a VB 2005 book, but using VB 2008. What is wrong with this code? I am using ASP.NET to write a web page. For each reference to:

ResultFahrenheit.Text
ResultCelsius.Text
ResultKelvin.Text

I get errors that say:
Name 'ResultFahrenheit' is not declared.
Name 'ResultCelsius' is not declared.
Name 'ResultKelvin' is not declared.

Each of these fields is a cell in a table. I tried naming the table to 'table1', then adding:

table1.ResultFahrenheit...

This took the error away from 'ResultFahrenheit', but put it on 'table1'. So, apparently the 'ResultFahrenheit' needs some type of prefix.

I'd appreciate any suggestions.
Thanks

' ----- The conversion occurs here.
        Dim origValue As Double

        If (IsNumeric(SourceValue.Text) = True) Then
            ' ----- The user supplied a number. Convert it.
            origValue = CDbl(SourceValue.Text)
            If (SourceType.SelectedValue = "F") Then
                ' ----- From Fahrenheit.
                ResultFahrenheit.Text = CStr(origValue)
                ResultCelsius.Text = CStr((origValue - 32) / 1.8)
                ResultKelvin.Text = CStr(((origValue - 32) / 1.8) + _
                   273.15)
            ElseIf (SourceType.SelectedValue = "C") Then
                ' ----- From Celsius.
                ResultFahrenheit.Text = CStr((origValue * 1.8) + 32)
                ResultCelsius.Text = CStr(origValue)
                ResultKelvin.Text = CStr(origValue + 273.15)
            Else
                ' ----- From kelvin.
                ResultFahrenheit.Text = CStr(((origValue - 273.15) * _
                   1.8) + 32)
                ResultCelsius.Text = CStr(origValue - 273.15)
                ResultKelvin.Text = CStr(origValue)
            End If
        Else
            ' ----- Unknown source value.
            ResultFahrenheit.Text = "???"
            ResultCelsius.Text = "???"
            ResultKelvin.Text = "???"
        End If

the are labels or some other GUI component

do you have labels with these names?

and 2005 and 2008 use 99% of the same code, its not a problem there

Try to find the Table, TableRow, TableCells OR Fields with yourPage.FindControl("")
If the control will be found the value can be added to it. As jbennet says, the code didn't change thát much.... so it's strange it worked in 2005 and not in 2008.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.