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